[Numpy-discussion] Segmentation fault

David Cournapeau david@ar.media.kyoto-u.ac...
Thu Apr 17 04:59:24 CDT 2008

Anne-Sophie Sertier wrote:
> Hello !
> I'm a new user of Numpy. I want to use it to work with matrices (very
> huge matrices), select column, make product, etc ...
> Configuration : Debian, python 2.4.4 and numpy 1.0.1
> So here is my problem:
> I initialize a matrix which will contain only 0 and 1
>  >>> from numpy import *
>>>> matCons = zeros((194844,267595)),dtype=int8)

Unless you are executing this on a gigantic computer, this won't work 
very well: you are asking to create an array which has ~ 2e5^2 elements, 
that is around 40 Gb.

There is a bug, but the bug happens at the above line: the zeros call 
did not fail whereas it should have. It is likely caused because the 
number of elements cannot fit into a 32 bits integers, which means it 

import numpy as np
n , m = 1e5,1e5
a = np.zeros((n, m), np.int8)
assert a.size == n * m

Will raise an assertion error (n * m is just big enough to not fit into 
a 32 bits integer in this case).



More information about the Numpy-discussion mailing list