简体   繁体   English

Numpy 在运行 Python 文件时出现内存错误

[英]Numpy gives memory error while running a Python file

I'm trying to run a Python file, but every time it gives me this error.我正在尝试运行一个 Python 文件,但每次它都给我这个错误。 What could be the cause of this error and a possible solution?此错误的原因和可能的解决方案是什么? I'm using the latest version of numpy-1.17.0我正在使用最新版本的 numpy-1.17.0

numpy.core._exceptions.MemoryError: Unable to allocate array with shape 
(129941, 400, 16) and data type int32

I think your array is too big.我认为你的数组太大了。 int32 is 32 bits so 4 bytes and 4*129941*400*16 = 3326489600 bytes = 3.3264896 Gigabytes . int32是 32 位,所以 4 bytes 和4*129941*400*16 = 3326489600 bytes = 3.3264896 Gigabytes

This is likely due to your system's overcommit handling mode .这可能是由于您系统的overcommit handling mode
In the default mode, 0 ,在默认模式下, 0
You can check it using您可以使用

$ cat /proc/sys/vm/overcommit_memory

You have to set it 1 ,using你必须将它设置为1 ,使用

$ echo 1 | sudo tee /proc/sys/vm/overcommit_memory

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM