Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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])
share|improve this question
9  
Either buy 134 GB of RAM or make a smaller array. –  Jaime May 16 '14 at 4:24

1 Answer 1

up vote 4 down vote accepted

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+'.

share|improve this answer
    
Weird, I have hundreds of Gigs left but it says the following error: [Errno 28] No space left on device –  robertevansanders May 16 '14 at 22:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.