MemoryError: 无法分配形状为(200,20,244,244,3)和数据类型float64的数组

2024-05-20 12:27:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图从位于HERE的Github repo运行一个培训模块。我是在云服务器上运行的,但我不知道为什么经过几轮之后,我会得到这个错误:

Traceback (most recent call last):
  File "run.py", line 229, in <module>
    classes=classes, use_augs=use_augs, fix_lens=fix_lens)
  File "run.py", line 165, in hyper_tune_network
    classes=classes)
  File "run.py", line 111, in get_generators
    classes=classes)
  File "/home/code/datasetBuilder.py", line 221, in get_sequences
    X = pad_sequences(X, maxlen=seq_length, padding='pre', truncating='pre')
  File "/usr/local/lib/python3.5/dist-packages/keras/preprocessing/sequence.py", line 61, in pad_sequences
    x = (np.ones((num_samples, maxlen) + sample_shape) * value).astype(dtype)
  File "/root/.local/lib/python3.5/site-packages/numpy/core/numeric.py", line 214, in ones
    a = empty(shape, dtype, order)

    MemoryError: Unable to allocate array with shape (200, 20, 244, 244, 3) and data type float64

第一,这是什么意思?有什么办法解决吗?解决办法是什么?


Tags: runinpygetuselinefixclasses
1条回答
网友
1楼 · 发布于 2024-05-20 12:27:55

这与linux如何处理RAM过度使用有关(我假设您运行的是linux)。如果您的请求太多,您的进程将被终止,或者您得到一个错误,如您所描述的。作为根目录,您可以尝试:

echo 1 > /proc/sys/vm/overcommit_memory

这会让你想要求多少就要求多少。如果请求太多,仍然会出现内存不足错误,但这将允许您使用更大的数组。

相关问题 更多 >