Skip to content

numpy.linalg.svd did not converge with normal ndarray #12941

@ribes96

Description

@ribes96

I found and array on which numpy.linalg.svd fails. It is this one:
bad_array.zip

Reproducing code example:

import numpy as np
from numpy.linalg import svd

path = 'bad_array.npy'
X = np.load(path)

print(np.isnan(X).any())
# False

svd(X)

Error message:

Traceback (most recent call last):
  File "test.py", line 10, in <module>
    svd(X)
  File "/home/hobber/.virtualenvs/tfg_env/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 1612, in svd
    u, s, vh = gufunc(a, signature=signature, extobj=extobj)
  File "/home/hobber/.virtualenvs/tfg_env/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 106, in _raise_linalgerror_svd_nonconvergence
    raise LinAlgError("SVD did not converge")
numpy.linalg.LinAlgError: SVD did not converge

It might be an issue on OpenBlas. See scipy/scipy#9620

>>> numpy.show_config()
blas_mkl_info:
  NOT AVAILABLE
blis_info:
  NOT AVAILABLE
openblas_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
lapack_mkl_info:
  NOT AVAILABLE
openblas_lapack_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
lapack_opt_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]

I don't know how to see the OpenBlas version, but as it is NumPy 1.16.1, it is expected to be OpenBLAS v0.3.4+. It was supposed to be fixed with this release, but here it is again.

Scipy version of svd doesn't fail, maybe because it is stil using an older version of OpenBlas

>>> scipy.__version__
'1.2.0'

Everything is installed from PyPI, with pip

$ sudo lshw | grep -i cpu
     *-cpu                  
          description: CPU
          product: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
          bus info: cpu@0
          version: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
          capabilities: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d cpufreq

With OMP_NUM_THREADS=1 it doesn't fail.

Numpy/Python version information:

NumPy version: '1.16.1'
Python version: 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions