[SciPy-User] segfault using _sparse_ svd, eigen, eigen_symmetric with svn 0.9.0.dev6598
Skipper Seabold
jsseabold at gmail.com
Wed Jul 21 12:27:18 EDT 2010
On Wed, Jul 21, 2010 at 11:59 AM, Jose Quesada <quesada at gmail.com> wrote:
> Hi,
>
> We are on a coding sprint trying to implement sparse matrix support in MDP
> (http://sourceforge.net/apps/mediawiki/mdp-toolkit/index.php?title=MDP_Sprint_2010).
> The new sparse.linalg is very useful here.
>
> We are getting segfaults using _sparse_ svd, eigen, eigen_symmetric with svn
> 0.9.0.dev6598. I understand that (1) this is an unreleased version, and (2)
> these methods may depend on external C and fortran code that could have not
> being installed well on my machine, so this may be difficult to debug. I
> have added instructions to reproduce the segfault, but please ask for
> anything else that could be needed and I'll try to provide it.
>
> I installed the svn version on a virtualenv using pip:~/.virtualenvs/sprint$
> pip install svn+http://svn.scipy.org/svn/scipy/trunk/#egg=scipyc
>
> This generates a long log that could contain the explanation, so I posted it
> here (going as far back as my terminal's scrollback enabled:
> http://pastebin.org/410867
>
> Last, here's an example that reproduces the segfault:
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
>
> #--------------------------
> # simply run an svd on a a sparse matrix, svn 0.9.0.dev6598
> #--------------------------
> import scipy
> from scipy import sparse
> from numpy.random import rand
>
> # create random sparse matrix
> x = scipy.sparse.lil_matrix((1000000, 1000000))
> x[0, :100] = rand(100)
> x[1, 100:200] = x[0, :100]
> x.setdiag(rand(1000))
> x = x.tocsr() # convert it to CSR
> #v, u, w = scipy.sparse.linalg.eigen_symmetric(x) # segmentation fault
>
> # try a simpler matrix
> y = scipy.sparse.lil_matrix((10, 10))
> y.setdiag(range(10))
> y = y.tocsr() # convert it to CSR
> #v, u, w = scipy.sparse.linalg.eigen_symmetric(y) #
>
I have to import the linalg separately, and my docs say that
eigen_symmetric only returns w and v, so I can do
import scipy.sparse.linalg as splinalg
w, v = splinalg.eigen_symmetric(y)
without a segfault.
I'm running the most recent git mirror version of scipy. Just
installed this morning. I don't know how to check the git concept of
a revision number yet...
> #./sampleSegFault.py
> #Traceback (most recent call last):
> #File "./sampleSegFault.py", line 13, in <module>
> #x[0, :100] = rand(100)
> #File
> "/home/quesada/.virtualenvs/sprint/lib/python2.6/site-packages/scipy/sparse/lil.py",
> line 319, in __setitem__
> #x = lil_matrix(x, copy=False)
> #File
> "/home/quesada/.virtualenvs/sprint/lib/python2.6/site-packages/scipy/sparse/lil.py",
> line 98, in __init__
> #A = csr_matrix(A, dtype=dtype).tolil()
> #File
> "/home/quesada/.virtualenvs/sprint/lib/python2.6/site-packages/scipy/sparse/compressed.py",
> line 71, in __init__
> #self._set_self( self.__class__(coo_matrix(arg1, dtype=dtype)) )
> #File
> "/home/quesada/.virtualenvs/sprint/lib/python2.6/site-packages/scipy/sparse/coo.py",
> line 171, in __init__
> #self.data = M[self.row,self.col]
> #ValueError: shape mismatch: objects cannot be broadcast to a single
> shape
> #*** glibc detected *** python: double free or corruption (!prev):
> 0x0000000004075ec0 ***
>
>
> # some other linalg methods
> ly,v = scipy.sparse.linalg.eig(y) # segmentation fault
>
I don't have splinalg.eig, but I have splinalg.eigen and it works
without segfault. Probably a bad install is my guess. I don't use
pip, but you might want to just try building from source and provide
the full output of the build process.
Skipper
More information about the SciPy-User
mailing list