pythonarraysnumpylimitmemory-access

Access Violation (0xC0000005) NumPy array


I have this simple NumPy/Python code below:

from numpy import zeros, float32

v = 3039345
d = 400
i = 354993
j = 0

var1 = zeros((v,d), dtype=float32)
var1[i, j] = 0 #the problem pops here

when the last line is interpreted, I have this:

Process finished with exit code -1073741819 (0xC0000005)

If i < 354993 the execution is fine. I am using Python 2.7 32-bit over Windows 8 64-bit. It is due to a limit in Memory? in this case what would be the best solution to have this working?


Solution

  • It is caused by the 32 bit version of numpy binaries. Numpy does calculate the size of the allocated memory region using platform-specific integers, and the size of the array measured in bytes does not fit in 2**32. It sounds like a bug, as it should raise an error at array creation in my opinion.

    You can install 64 bit version of any python and numpy, and that will fix your problem.