4

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?

5
  • For me it doesn't crash (Python3.5 Windows 8.1 64 bits) Commented Jan 7, 2016 at 22:44
  • Hey, are you using 64-bit python as well? Commented Jan 7, 2016 at 22:48
  • Yes, 64bit python3, Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32 to be exact Commented Jan 7, 2016 at 22:50
  • 32bit python2.7 fails on my machine Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32 with access violation: Unhandled exception at 0x1000696C (multiarray.pyd) in python2.exe: 0xC0000005: Access violation writing location 0x40029260. Commented Jan 7, 2016 at 22:53
  • I suspect the reason is the array size is greater than 2**32 measured in bytes Commented Jan 7, 2016 at 22:55

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.