Reputation: 7313
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])
Upvotes: 3
Views: 4256
Reputation: 58955
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+'
.
Upvotes: 8