3

I need to store a ton of information in a numpy array. It needs to be of the following shape:

facefeature1s = np.empty([2000,64,64,64,32])

When I run this, i get a memory error. What can I do about this?

Error is:

    MemoryError                               Traceback (most recent call last)
<ipython-input-271-2c56a37b4a7c> in <module>()
----> 1 facefeature1s = np.empty([2000,64,64,64,32])
1
  • 9
    Either buy 134 GB of RAM or make a smaller array. Commented May 16, 2014 at 4:24

1 Answer 1

8

As @Jaime says in the comments, your array is too big. IF you really need such a huge array, you can use numpy.memmap() to work on the array using the hard drive:

a = np.memmap('filename.myarray', dtype=np.float64, mode='w+',
              shape=(2000, 64, 64, 64, 32))

The next time you open the array, use mode='r', or mode='r+'.

Sign up to request clarification or add additional context in comments.

1 Comment

Weird, I have hundreds of Gigs left but it says the following error: [Errno 28] No space left on device

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.