Skip to content

LinAlgError in test_spectral_lobpcg_mode with scipy 0.13.3 #2924

Closed

Description

@ogrisel

On Ubuntu 13.10 (Saucy), with numpy 1.8.0 and scipy 0.13.3, I get the following failure:

======================================================================
ERROR: sklearn.cluster.tests.test_spectral.test_spectral_lobpcg_mode
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vagrant/venvs/2.7/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/vagrant/code/scikit-learn/sklearn/cluster/tests/test_spectral.py", line 68, in test_spectral_lobpcg_mode
    random_state=0, eigen_solver="lobpcg")
  File "/home/vagrant/code/scikit-learn/sklearn/cluster/spectral.py", line 255, in spectral_clustering
    eigen_tol=eigen_tol, drop_first=False)
  File "/home/vagrant/code/scikit-learn/sklearn/manifold/spectral_embedding_.py", line 303, in spectral_embedding
    largest=False, maxiter=2000)
  File "/home/vagrant/venvs/2.7/local/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py", line 411, in lobpcg
    activeBlockVectorBP, retInvR=True)
  File "/home/vagrant/venvs/2.7/local/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py", line 148, in b_orthonormalize
    gramVBV = sla.cholesky(gramVBV)
  File "/home/vagrant/venvs/2.7/local/lib/python2.7/site-packages/scipy/linalg/decomp_cholesky.py", line 81, in cholesky
    check_finite=check_finite)
  File "/home/vagrant/venvs/2.7/local/lib/python2.7/site-packages/scipy/linalg/decomp_cholesky.py", line 30, in _cholesky
    raise LinAlgError("%d-th leading minor not positive definite" % info)
LinAlgError: 2-th leading minor not positive definite

----------------------------------------------------------------------

The libatlas3-base and libatlas-dev packages are installed.

Activity

  1. ogrisel commented on Mar 3, 2014

    @ogrisel
    MemberAuthor

    @larsmans @GaelVaroquaux: I found the cause of the problem: by default /usr/lib/liblapack.so.3 is a symlink to the original lapack implementation:

    /usr/lib/lapack/liblapack.so.3
    

    If you use update-alternatives to symlink it to the Atlas implementation, the tests pass:

    sudo update-alternatives --set liblapack.so.3 /usr/lib/atlas-base/atlas/liblapack.so.3
    

    I will issue a PR to update the doc on this matter. We could also try to make the test more robust to work on the original lapack but I am not sure it's worth it.

  2. ogrisel commented on Mar 3, 2014

    @ogrisel
    MemberAuthor

    The PR for the updated doc is here: #2926. The reference implementation of LAPACK /usr/lib/lapack/liblapack.so.3 is actually used when OpenBLAS is selected for providing BLAS. So it would indeed be worth making the test more robust.

  3. added a commit that references this issue on Mar 3, 2014
    61998ac
  4. ogrisel commented on Mar 3, 2014

    @ogrisel
    MemberAuthor

    PR submitted in #2928: ping @GaelVaroquaux and @larsmans.

  5. larsmans commented on Mar 3, 2014

    @larsmans
    Member

    Also confirmed that it works fine with ATLAS. I had apparently reset my alternatives while trying to get SciPy 0.9 to build.

  6. larsmans commented on Mar 3, 2014

    @larsmans
    Member

    Even with ATLAS it would be a good idea to fix the test. Turns out Debian prefers the reference LAPACK, giving it a higher priority:

    $ update-alternatives --display liblapack.so
    liblapack.so - auto mode
      link currently points to /usr/lib/lapack/liblapack.so
    /usr/lib/atlas-base/atlas/liblapack.so - priority 5
      slave liblapack.a: /usr/lib/atlas-base/atlas/liblapack.a
    /usr/lib/lapack/liblapack.so - priority 20
      slave liblapack.a: /usr/lib/lapack/liblapack.a
    Current 'best' version is '/usr/lib/lapack/liblapack.so'.
    

    (same for .so.3).

  7. ogrisel commented on Mar 3, 2014

    @ogrisel
    MemberAuthor

    The #2928 makes the test pass both with reference lapack and with the atlas impl.

  8. kmike commented on May 13, 2014

    @kmike
    Contributor

    Not sure why, but I'm still getting this test failed with scikit-learn master. OS X 10.9.2, Python 2.7.5, numpy 1.8.1, scipy 0.13.3, Accelerate framework.

    EDIT: Sorry, I was using a wrong scikit-learn version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions