我在Ubuntu 18上在numpy中分配大型数组时遇到了一个问题,而在MacOS上却没有遇到同样的问题。
我想一个numpy的阵列形状分配内存(156816, 36, 53806)
使用
np.zeros((156816, 36, 53806), dtype='uint8')
Run Code Online (Sandbox Code Playgroud)
当我在Ubuntu OS上遇到错误时
>>> import numpy as np
>>> np.zeros((156816, 36, 53806), dtype='uint8')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
numpy.core._exceptions.MemoryError: Unable to allocate array with shape (156816, 36, 53806) and data type uint8
Run Code Online (Sandbox Code Playgroud)
我在MacOS上没有得到它:
>>> import numpy as np
>>> np.zeros((156816, 36, 53806), dtype='uint8')
array([[[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0], …
Run Code Online (Sandbox Code Playgroud) 我有一个python脚本在与我要转换为numpy数组的视频相同的文件夹中.我的视频名为'test.mp4'.
在我的脚本中,我想调用someFunction('test.mp4')
并返回一个numpy数组.生成的numpy数组应该是一个numpy数组,其中每个图像都是一个3-d numpy数组.
那有意义吗?
谢谢!