Numpy: np.dot stürzt auf einigen Systemen mit numpy 1.14.5 ab

Erstellt am 6. Juli 2018  ·  61Kommentare  ·  Quelle: numpy/numpy

Auf einem unserer Systeme führt das folgende Codefragment zu einem Absturz des Python-Interpreters:

import numpy as np
A = np.matrix([[1.], [3.]])
B = np.matrix([[2., 3.]])
np.dot(A, B)

Ein paar Details:

  • Windows 10
  • Python 3.5.2 in einer virtuellen Umgebung
  • numpy 1.14.5

Auf anderen Systemen funktioniert dieser Befehl einwandfrei.

00 - Bug

Alle 61 Kommentare

Woher bekommst du deine Nummer? Pip? Anakonda? Was sagt np.show_config() ?

Danke für die Antwort. Ich habe numpy durch pip installiert.

>>> import numpy as np
>>> np.show_config()
blas_mkl_info:
  NOT AVAILABLE
openblas_lapack_info:
    library_dirs = ['C:\\projects\\numpy-wheels-jc1cl\\numpy\\build\\openblas']
    libraries = ['openblas']
    define_macros = [('HAVE_CBLAS', None)]
    language = f77
blis_info:
  NOT AVAILABLE
lapack_mkl_info:
  NOT AVAILABLE
openblas_info:
    library_dirs = ['C:\\projects\\numpy-wheels-jc1cl\\numpy\\build\\openblas']
    libraries = ['openblas']
    define_macros = [('HAVE_CBLAS', None)]
    language = f77
lapack_opt_info:
    library_dirs = ['C:\\projects\\numpy-wheels-jc1cl\\numpy\\build\\openblas']
    libraries = ['openblas']
    define_macros = [('HAVE_CBLAS', None)]
    language = f77
blas_opt_info:
    library_dirs = ['C:\\projects\\numpy-wheels-jc1cl\\numpy\\build\\openblas']
    libraries = ['openblas']
    define_macros = [('HAVE_CBLAS', None)]
    language = f77

Aktualisiert auf die neueste Microsoft Visual C-Laufzeit auf dem Computer
Hilfe? Möglicherweise verfügbar von Windows Update oder von:
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

@pv danke für den Hinweis, aber nach der Installation der neuesten Laufzeit 2017 und dem Neustart des Systems bleibt der Fehler weiterhin bestehen.

Vielleicht hat es nichts mit dem Problem zu tun, aber das betroffene System ist Windows 10, das in einer KVM ausgeführt wird.

Wenn ich das obige Testskript folgendermaßen als t.py ausführe: python -u -m trace -t t.py , erhalte ich vor dem Absturz die folgende Ausgabe:

t.py(4): A = np.matrix([[1.], [3.]])
 --- modulename: defmatrix, funcname: __new__
defmatrix.py(213):         if isinstance(data, matrix):
defmatrix.py(221):         if isinstance(data, N.ndarray):
defmatrix.py(232):         if isinstance(data, str):
defmatrix.py(236):         arr = N.array(data, dtype=dtype, copy=copy)
defmatrix.py(237):         ndim = arr.ndim
defmatrix.py(238):         shape = arr.shape
defmatrix.py(239):         if (ndim > 2):
defmatrix.py(241):         elif ndim == 0:
defmatrix.py(243):         elif ndim == 1:
defmatrix.py(246):         order = 'C'
defmatrix.py(247):         if (ndim == 2) and arr.flags.fortran:
defmatrix.py(248):             order = 'F'
defmatrix.py(250):         if not (order or arr.flags.contiguous):
defmatrix.py(253):         ret = N.ndarray.__new__(subtype, shape, arr.dtype,
defmatrix.py(254):                                 buffer=arr,
defmatrix.py(255):                                 order=order)
 --- modulename: defmatrix, funcname: __array_finalize__
defmatrix.py(259):         self._getitem = False
defmatrix.py(260):         if (isinstance(obj, matrix) and obj._getitem): return
defmatrix.py(261):         ndim = self.ndim
defmatrix.py(262):         if (ndim == 2):
defmatrix.py(263):             return
defmatrix.py(256):         return ret
t.py(5): B = np.matrix([[2., 3.]])
 --- modulename: defmatrix, funcname: __new__
defmatrix.py(213):         if isinstance(data, matrix):
defmatrix.py(221):         if isinstance(data, N.ndarray):
defmatrix.py(232):         if isinstance(data, str):
defmatrix.py(236):         arr = N.array(data, dtype=dtype, copy=copy)
defmatrix.py(237):         ndim = arr.ndim
defmatrix.py(238):         shape = arr.shape
defmatrix.py(239):         if (ndim > 2):
defmatrix.py(241):         elif ndim == 0:
defmatrix.py(243):         elif ndim == 1:
defmatrix.py(246):         order = 'C'
defmatrix.py(247):         if (ndim == 2) and arr.flags.fortran:
defmatrix.py(248):             order = 'F'
defmatrix.py(250):         if not (order or arr.flags.contiguous):
defmatrix.py(253):         ret = N.ndarray.__new__(subtype, shape, arr.dtype,
defmatrix.py(254):                                 buffer=arr,
defmatrix.py(255):                                 order=order)
 --- modulename: defmatrix, funcname: __array_finalize__
defmatrix.py(259):         self._getitem = False
defmatrix.py(260):         if (isinstance(obj, matrix) and obj._getitem): return
defmatrix.py(261):         ndim = self.ndim
defmatrix.py(262):         if (ndim == 2):
defmatrix.py(263):             return
defmatrix.py(256):         return ret
t.py(6): print(np.dot(A, B))
 --- modulename: defmatrix, funcname: __array_finalize__
defmatrix.py(259):         self._getitem = False
defmatrix.py(260):         if (isinstance(obj, matrix) and obj._getitem): return
defmatrix.py(261):         ndim = self.ndim
defmatrix.py(262):         if (ndim == 2):
defmatrix.py(263):             return

Hmm,

Dieser funktioniert

A = np.matrix([[1.], [3.]])
B = np.matrix([[2., 3.]])
print(np.dot(A.astype(np.float16), B.astype(np.float16)))

Dieser stürzt ab

A = np.matrix([[1.], [3.]])
B = np.matrix([[2., 3.]])
print(np.dot(A.astype(np.float32), B.astype(np.float32)))

Irgendeine Idee?

Nachdem ich mit verschiedenen Numpy-Versionen herumgespielt habe, kann ich das sagen

  • numpy <= 1.13.1 ist nicht betroffen, während
  • numpy> = 1.13.3 ist von diesem Problem betroffen
  • numpy 1.13.2 wurde nicht getestet, da kein Build auf pypi vorhanden ist

Ich sehe keine offensichtlichen Änderungen, die dazu führen könnten. Da das Problem für diese Installation spezifisch ist, kann es hilfreich sein, festzustellen, ob die Umgebung, die Hardware usw. etwas Besonderes sind. Ich vermute, dass irgendwo ein Bibliotheksproblem vorliegt.

An welchen Informationen interessieren Sie sich?

OS Name Microsoft Windows 10 Pro
Version 10.0.16299 Build 16299
Other OS Description    Not Available
OS Manufacturer Microsoft Corporation
System Name <REMOVED>
System Manufacturer QEMU
System Model    Standard PC (i440FX + PIIX, 1996)
System Type x64-based PC
System SKU  
Processor   Common KVM processor, 1996 Mhz, 4 Core(s), 4 Logical Processor(s)
BIOS Version/Date   SeaBIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org, 4/1/2014
SMBIOS Version  2.8
Embedded Controller Version 255.255
BIOS Mode   Legacy
Platform Role   Desktop
Secure Boot State   Unsupported
PCR7 Configuration  Binding Not Possible
Windows Directory   C:\WINDOWS
System Directory    C:\WINDOWS\system32
Boot Device \Device\HarddiskVolume1
Locale  Austria
Hardware Abstraction Layer  Version = "10.0.16299.371"
User Name   Not Available
Time Zone   W. Europe Daylight Time
Installed Physical Memory (RAM) 4.00 GB
Total Physical Memory   4.00 GB
Available Physical Memory   1.94 GB
Total Virtual Memory    8.00 GB
Available Virtual Memory    5.27 GB
Page File Space 4.00 GB
Page File   C:\pagefile.sys
Virtualization-based security   Not enabled
Device Encryption Support   Reasons for failed automatic device encryption: TPM is not usable, PCR7 binding is not supported, Hardware Security Test Interface failed and device is not InstantGo, Un-allowed DMA capable bus/device(s) detected, Disabled by policy, TPM is not usable
A hypervisor has been detected. Features required for Hyper-V will not be displayed.    

Ich suche nach Unterschieden mit Ihren Arbeitsinstallationen. Sieht aus wie das Basissystem Linux ist?

Es funktioniert auf:

  • alle physischen Windows 10-Installationen
  • in einer Windows 10 Hyper-V-VM mit Windows 10-Host

Ich habe kein anderes, ähnliches Windows 10-Setup, mit dem ich das betroffene System vergleichen könnte.

Sieht aus wie das Basissystem Linux ist?

Genau: Debian GNU / Linux 9 (Stretch)

Die NumPy-Änderung, die dies wahrscheinlich ausgelöst hat, war der Wechsel zu OpenBLAS unter Windows für 1.13.3. Ich gehe davon aus, dass in der numerischen KVM-Umgebung etwas optimiert werden muss.

Könnte auch prüfen, ob eine Atlas-DLL im Umlauf ist.

Könnte auch prüfen, ob eine Atlas-DLL im Umlauf ist.

Was genau meinst du mit diesem Satz?

Es sollte eine openblas-DLL für die späteren Versionen geben, daher frage ich mich, ob es möglicherweise zu Verwechslungen mit einer älteren Atlas-DLL kommen könnte. Wahrscheinlich nicht. IIUC, numpy läuft, es gibt nur die falschen Ergebnisse zurück.

Numpy läuft, aber für das obige Beispiel wird nichts wiederholt, was jedoch zu einem Absturz führt.

Eine andere Möglichkeit besteht darin, dass OpenBLAS eine illegale Anweisung (SSE *) ausgibt, die in der KVM-Umgebung nicht unterstützt wird. Ich weiß nicht, was dort aktiviert ist. Können Sie das überprüfen?

Sie können OpenBlas über Umgebungsvariablen steuern. set OPENBLAS_VERBOSE=2 sollte das verwendete Standardprozessormodell ausdrucken. Es scheint, dass der Gast dasselbe Modell wie die eigentliche Host-Hardware verwenden muss. Es gibt also beispielsweise set OPENBLAS_CORETYPE=nehalem wenn dies für Ihren Host-Computer korrekt ist. Verhält sich NumPy auf dem Host-Computer ordnungsgemäß? In diesem Fall können Sie die ausführliche Einstellung verwenden, um herauszufinden, was der Gast verwenden soll

Weitere Informationen zu diesem Problem?

Das Problem besteht immer noch, aber ich konnte die Dinge @mattip noch nicht testen und Sie haben es erwähnt. Ich werde dies in den nächsten zwei Wochen nicht tun können, aber ich werde es danach tun.

OK danke.

@ m55c55 Hast du es geschafft, dies nicht mehr zu debuggen?

Hallo,
Ich kann dieses Problem bestätigen und kann helfen, indem ich einen anderen Anwendungsfall gebe ...

Ich habe ein sehr ähnliches Verhalten auf meinem Computer (neue Linux-Installation):

Linux 4.15.0-42-generic #45-Ubuntu SMP Thu Nov 15 19:32:57 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Ubuntu 18.04.1 LTS

numpy (1.15.4)

>>> np.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)]

Mein Python-Skript:

import numpy as np
A = np.random.randn(100, 3000)
B = np.random.randn(3000, 100)
np.dot(B, A)

Das Skript stürzt nicht mit sehr kleinen Matrizen ab.

Der Absturz ist jedoch tatsächlich kritisch: Der Computer startet sofort neu und viele Dateien sind beschädigt (meine Bash und das Numpy-Modul sind während meiner Untersuchung kaputt gegangen).

Ich nehme an, du meinst np.dot(B, A.T) ? Wie bist du zu NumPy gekommen? Wenn Sie selbst gebaut haben, welche Version von OpenBLAS?

Nein, es sollte np.dot(B, A) , um die Abmessungen auszurichten.

Ich habe versucht, von pip numpy zu bekommen (1.15.4)

➜  ~ pip3 install numpy
Collecting numpy
  Using cached https://files.pythonhosted.org/packages/ff/7f/9d804d2348471c67a7d8b5f84f9bc59fd1cefa148986f2b74552f8573555/numpy-1.15.4-cp36-cp36m-manylinux1_x86_64.whl

Und auch aus Ubuntu-Repositories (1.13.3) ausprobiert

➜  ~ apt-cache show python3-numpy
Package: python3-numpy
Architecture: amd64
Version: 1:1.13.3-2ubuntu1
Priority: optional
Section: python
Source: python-numpy
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Sandro Tosi <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 10670
Provides: python3-f2py, python3-numpy-abi9, python3-numpy-api11, python3-numpy-dev, python3.6-numpy
Depends: python3 (<< 3.7), python3 (>= 3.6~), python3.6:any, python3:any (>= 3.4~), libblas3 | libblas.so.3, libc6 (>= 2.14), liblapack3 | liblapack.so.3
Suggests: gcc (>= 4:4.6.1-5), gfortran, python-numpy-doc, python3-dev, python3-nose (>= 1.0), python3-numpy-dbg
Filename: pool/main/p/python-numpy/python3-numpy_1.13.3-2ubuntu1_amd64.deb
Size: 1942804
MD5sum: 7b84ea9967f987a292b64f5bc5b6d65f
SHA1: 73fd8354b7106ac81b8add37947173aad515a9d5
SHA256: 3098ad88b8404cbeee66cc6eef96b13ea87eda848900d7cb754fd0bf280741bf

Ich habe es gerade auf einem anderen Computer mit Ubuntu 18 versucht und pip hat numpy installiert ... und kann den Absturz nicht reproduzieren. Nicht sicher, was los ist!

Hallo, ich habe diesen Fehler beim Ausführen der Corrcoef-Funktion festgestellt. Ich habe einen Drilldown durchgeführt und festgestellt, dass ich den Absturz mit dem folgenden Aufruf np.dot(np.array([[0], [0]]), np.array([0, 0]).conj()) reproduzieren kann

Ich laufe Windows 10 in einer Anaconda-Umgebung.

np.__version__

1.14.2

np.show_config ()

mkl_info:
    libraries = ['mkl_rt']
    library_dirs = ['C:/Users/tommassino/AppData/Local/Continuum/Anaconda3/envs/project-conda\\Library\\lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl\\include', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl\\lib', 'C:/Users/tommassino/AppData/Local/Continuum/Anaconda3/envs/project-conda\\Library\\include']
blas_mkl_info:
    libraries = ['mkl_rt']
    library_dirs = ['C:/Users/tommassino/AppData/Local/Continuum/Anaconda3/envs/project-conda\\Library\\lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl\\include', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl\\lib', 'C:/Users/tommassino/AppData/Local/Continuum/Anaconda3/envs/project-conda\\Library\\include']
blas_opt_info:
    libraries = ['mkl_rt']
    library_dirs = ['C:/Users/tommassino/AppData/Local/Continuum/Anaconda3/envs/project-conda\\Library\\lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl\\include', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl\\lib', 'C:/Users/tommassino/AppData/Local/Continuum/Anaconda3/envs/project-conda\\Library\\include']
lapack_mkl_info:
    libraries = ['mkl_rt']
    library_dirs = ['C:/Users/tommassino/AppData/Local/Continuum/Anaconda3/envs/project-conda\\Library\\lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl\\include', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl\\lib', 'C:/Users/tommassino/AppData/Local/Continuum/Anaconda3/envs/project-conda\\Library\\include']
lapack_opt_info:
    libraries = ['mkl_rt']
    library_dirs = ['C:/Users/tommassino/AppData/Local/Continuum/Anaconda3/envs/project-conda\\Library\\lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl\\include', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2016.4.246\\windows\\mkl\\lib', 'C:/Users/tommassino/AppData/Local/Continuum/Anaconda3/envs/project-conda\\Library\\include']

@Tommassino Kann nicht reproduzieren. Sind Sie sicher, dass dies die Formen sind, die versagen?
Bei diesem Problem geht es darum, in einer VM ausgeführt zu werden. Wenn Ihr Setup anders ist, öffnen Sie bitte ein neues Problem.

>>> import sys
>>> print(sys.version)
3.6.6 (default, Sep 12 2018, 18:26:19) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
>>> import numpy as np
>>> np.__version__
'1.14.2'
>>> np.dot(np.array([[0], [0]]), np.array([0, 0]).conj())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: shapes (2,1) and (2,) not aligned: 1 (dim 1) != 2 (dim 0)

@mattip Entschuldigung, ich habe nicht bemerkt, dass dies speziell mit einer VM-Umgebung zusammenhängt, da dies nur in den folgenden Beiträgen erwähnt wurde. Einige der anderen Antworten scheinen das Problem zu erwähnen, das bei Nicht-VMS auftritt. Mein Fehler mit dem Befehl np.dot, ich habe die Arrays aus meinem Debugger falsch kopiert.

>>> import sys
>>> import numpy as np
>>> print(sys.version)
3.6.6 | packaged by conda-forge | (default, Jul 26 2018, 11:48:23) [MSC v.1900 64 bit (AMD64)]
>>> print(np.__version__)
1.14.2
>>> X = np.array([0., 0.])
>>> X_T = np.array([0., 0.])
>>> print(X)
[0. 0.]
>>> print(X_T)
[0. 0.]
>>> print(np.dot(X, X_T.conj()))
Process finished with exit code 2

Ich habe jedoch bereits festgestellt, dass es möglicherweise mit mkl-Eingeborenen zusammenhängt, die nicht korrekt geladen werden. Dies könnte also tatsächlich ein weiteres Problem sein.

@Tommassino Hast du auch Numpy von Conda bekommen?

@ oleksandr-pavlyk: irgendwelche gedanken?

@Tommassino Hast du auch Numpy von Conda bekommen?

Entschuldigung für die späte Antwort, Feiertage ... Ja, ich benutze eine Conda Numpy

> conda list --no-pip | grep numpy
numpy                     1.14.2           py36h5c71026_1

Wie oben erwähnt, verschwand das Problem jedoch, als ich mkl ( conda update mkl ) aktualisierte.

Ich denke, wir können das wahrscheinlich schließen? @Khemal, da Sie Linux https://gist.github.com/seberg/ce4563f3cb00e33997e4f80675b80953 auf der Box veröffentlichen, auf der der Absturz auftritt? Das könnte Ihnen / uns sagen, was falsch ist, da dies mit ziemlicher Sicherheit mit den Blas zusammenhängt.

Es sei denn, es gibt wirklich ein Problem mit der Referenzzählung, aber ich wäre überrascht, wenn ich nicht zufällig auch andere Leute treffen würde.

Hallo.

Ich habe einige Rückverfolgungen zu diesem Problem gesammelt.

Python 3.6.7
numpy (1.15.4)

(.kfr-test-env) root<strong i="9">@whatever</strong>:/app# gdb python3
(gdb) run testcode.py 
Starting program: /app/.kfr-test-env/bin/python3 testcode.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff3c1b700 (LWP 29704)]

Thread 1 "python3" received signal SIGILL, Illegal instruction.
0x00007ffff4a5c204 in dgemm_oncopy_OPTERON_SSE3 () from /app/.kfr-test-env/lib/python3.6/site-packages/numpy/core/../.libs/libopenblasp-r0-8dca6697.3.0.dev.so
(gdb) bt
#0  0x00007ffff4a5c204 in dgemm_oncopy_OPTERON_SSE3 () from /app/.kfr-test-env/lib/python3.6/site-packages/numpy/core/../.libs/libopenblasp-r0-8dca6697.3.0.dev.so
#1  0x00007ffff6520630 in ?? () from /app/.kfr-test-env/lib/python3.6/site-packages/numpy/core/../.libs/libopenblasp-r0-8dca6697.3.0.dev.so
#2  0x00000000000000e0 in ?? ()
#3  0x00007ffff41275db in dgemm_tt () from /app/.kfr-test-env/lib/python3.6/site-packages/numpy/core/../.libs/libopenblasp-r0-8dca6697.3.0.dev.so
#4  0x00007ffff4052088 in cblas_dgemm () from /app/.kfr-test-env/lib/python3.6/site-packages/numpy/core/../.libs/libopenblasp-r0-8dca6697.3.0.dev.so
#5  0x00007ffff676d28f in ?? () from /app/.kfr-test-env/lib/python3.6/site-packages/numpy/core/multiarray.cpython-36m-x86_64-linux-gnu.so
#6  0x00007ffff6732c36 in ?? () from /app/.kfr-test-env/lib/python3.6/site-packages/numpy/core/multiarray.cpython-36m-x86_64-linux-gnu.so
#7  0x00007ffff673400a in ?? () from /app/.kfr-test-env/lib/python3.6/site-packages/numpy/core/multiarray.cpython-36m-x86_64-linux-gnu.so
#8  0x00000000005030d5 in _PyCFunction_FastCallDict (kwargs=<optimized out>, nargs=<optimized out>, args=<optimized out>, 
    func_obj=<built-in method dot of module object at remote 0x7ffff6a535e8>) at ../Objects/methodobject.c:231
#9  _PyCFunction_FastCallKeywords (kwnames=<optimized out>, nargs=<optimized out>, stack=<optimized out>, func=<optimized out>) at ../Objects/methodobject.c:294
#10 call_function.lto_priv () at ../Python/ceval.c:4837
#11 0x0000000000506859 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#12 0x0000000000504c28 in PyEval_EvalFrameEx (throwflag=0, f=Frame 0xadeb18, for file testcode.py, line 10, in <module> ()) at ../Python/ceval.c:4166
#13 _PyEval_EvalCodeWithName.lto_priv.1761 () at ../Python/ceval.c:4166
#14 0x0000000000506393 in PyEval_EvalCodeEx (closure=0x0, kwdefs=0x0, defcount=0, defs=0x0, kwcount=0, kws=0x0, argcount=0, args=0x0, locals=<optimized out>, 
    globals=<optimized out>, _co=<optimized out>) at ../Python/ceval.c:4187
#15 PyEval_EvalCode (co=<optimized out>, globals=<optimized out>, locals=<optimized out>) at ../Python/ceval.c:731
#16 0x0000000000634d52 in run_mod () at ../Python/pythonrun.c:1025
#17 0x0000000000634e0a in PyRun_FileExFlags () at ../Python/pythonrun.c:978
#18 0x00000000006385c8 in PyRun_SimpleFileExFlags () at ../Python/pythonrun.c:419
#19 0x00000000006387a5 in PyRun_AnyFileExFlags () at ../Python/pythonrun.c:81
#20 0x000000000063915a in run_file (p_cf=0x7fffffffe2fc, filename=<optimized out>, fp=<optimized out>) at ../Modules/main.c:340
#21 Py_Main () at ../Modules/main.c:810
#22 0x00000000004a6f10 in main (argc=2, argv=0x7fffffffe4f8) at ../Programs/python.c:69

@seberg das ist die Ausgabe:

Probing Multiarray
------------------
OpenBLAS:
    num threads: 2
    version info: DYNAMIC_ARCH NO_AFFINITY Opteron MAX_THREADS=64

Probing Linalg
--------------
OpenBLAS:
    num threads: 2
    version info: DYNAMIC_ARCH NO_AFFINITY Opteron MAX_THREADS=64

LDD information:
----------------
running: ldd /app/.kfr-test-env/lib/python3.6/site-packages/numpy/core/multiarray.cpython-36m-x86_64-linux-gnu.so
    linux-vdso.so.1 (0x00007ffe941ef000)
    libopenblasp-r0-8dca6697.3.0.dev.so => /app/.kfr-test-env/lib/python3.6/site-packages/numpy/core/../.libs/libopenblasp-r0-8dca6697.3.0.dev.so (0x00007f9319cea000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f931994c000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f931972d000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f931933c000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f931c800000)
    libgfortran-ed201abd.so.3.0.0 => /app/.kfr-test-env/lib/python3.6/site-packages/numpy/core/../.libs/libgfortran-ed201abd.so.3.0.0 (0x00007f9319042000)
running: ldd /app/.kfr-test-env/lib/python3.6/site-packages/numpy/linalg/_umath_linalg.cpython-36m-x86_64-linux-gnu.so
    linux-vdso.so.1 (0x00007ffda69d5000)
    libopenblasp-r0-8dca6697.3.0.dev.so => /app/.kfr-test-env/lib/python3.6/site-packages/numpy/linalg/../.libs/libopenblasp-r0-8dca6697.3.0.dev.so (0x00007f12097c1000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f12095a2000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f12091b1000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1208e13000)
    libgfortran-ed201abd.so.3.0.0 => /app/.kfr-test-env/lib/python3.6/site-packages/numpy/linalg/../.libs/libgfortran-ed201abd.so.3.0.0 (0x00007f1208b19000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f120c0ee000)

@mattip Ich habe die Umgebungsvariablen Dinge ausprobiert, die Sie erwähnt haben:

Mit dem os.environ["OPENBLAS_CORETYPE"] = "nehalem" funktioniert es, aber ohne funktioniert es nicht.

import os
os.environ["OPENBLAS_VERBOSE"] = "2"
os.environ["OPENBLAS_CORETYPE"] = "nehalem"
import numpy as np

A = np.matrix([[1.], [3.]])
B = np.matrix([[2., 3.]])
ret = np.dot(A, B)
print(ret)

@kfrendrich Ich denke du bist auch auf einer virtuellen Maschine oder so? Andernfalls liegt möglicherweise ein Problem mit der CPU-Erkennung in OpenBLAS vor. Wenn dies eine virtuelle Maschine ist, müssen Sie möglicherweise nur diese Umgebungsvariablen verwenden.

@seberg ja es ist eine virtuelle maschine

Dies klingt nach einem Fehler in der Art und Weise, wie OpenBLAS die CPU erkennt. Könnten Sie es ihnen melden? Ich konnte keine offene kvm Ausgabe finden, aber es gibt einige geschlossene

Ja, ich werde sie bald melden.

Reproduziert sich das noch?

Der gleiche Absturz mit numpy 1.17.3.

$ python
>>> import numpy as np
>>> A = np.matrix([[1.0], [3.0]])
>>> B = np.matrix([[2.0, 3.0]])
>>> ret = np.dot(A, B)
Illegal instruction (core dumped)

Dies ist wahrscheinlich der Grund für den Fehler, den ich abgefangen habe - Python stirbt mit der "Unzulässigen Anweisung (Core Dumped)", wenn versucht wird, Folgendes auszuführen:

import matplotlib.pyplot as plt
fig = plt.figure(figsize=(10,10))

Vorgeschlagene Lösung:

import os
os.environ["OPENBLAS_VERBOSE"] = "2"
os.environ["OPENBLAS_CORETYPE"] = "nehalem"
import numpy as np

funktioniert nicht :(

Hier ist die ganze Geschichte und Konfiguration:

$ python
Python 3.6.8 (default, Oct  9 2019, 14:04:01)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import numpy as np
>>> print(sys.version)
3.6.8 (default, Oct  9 2019, 14:04:01)
[GCC 8.3.0]
>>> print(np.__version__)
1.17.3
>>> np.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)]

CPU-Informationen (dies ist eine virtuelle Maschine):

$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 85
model name      : Intel Xeon Processor (Skylake)
stepping        : 4
microcode       : 0x1
cpu MHz         : 2199.998
cache size      : 4096 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl cpuid tsc_known_freq pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm pti fsgsbase smep erms
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs
bogomips        : 4399.99
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 85
model name      : Intel Xeon Processor (Skylake)
stepping        : 4
microcode       : 0x1
cpu MHz         : 2199.998
cache size      : 4096 KB
physical id     : 1
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl cpuid tsc_known_freq pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm pti fsgsbase smep erms
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs
bogomips        : 4399.99
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

processor       : 2
vendor_id       : GenuineIntel
cpu family      : 6
model           : 85
model name      : Intel Xeon Processor (Skylake)
stepping        : 4
microcode       : 0x1
cpu MHz         : 2199.998
cache size      : 4096 KB
physical id     : 2
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 2
initial apicid  : 2
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl cpuid tsc_known_freq pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm pti fsgsbase smep erms
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs
bogomips        : 4399.99
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

processor       : 3
vendor_id       : GenuineIntel
cpu family      : 6
model           : 85
model name      : Intel Xeon Processor (Skylake)
stepping        : 4
microcode       : 0x1
cpu MHz         : 2199.998
cache size      : 4096 KB
physical id     : 3
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 3
initial apicid  : 3
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl cpuid tsc_known_freq pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm pti fsgsbase smep erms
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs
bogomips        : 4399.99
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

@prokulski wie hast du openblas installiert? Welche Version benutzt du? Wenn Sie das Github-Repository überprüfen, können Sie festlegen, welche Version sich auf welche Weise verhalten soll.

openblas wurde automatisch installiert (als Abhängigkeit von etwas). Ich habe versucht, es zu entfernen und erneut zu installieren (über apt install) - hat nicht geholfen

Ich gehe davon aus, dass dies auch mit regulären Arrays abstürzt (anstelle von np.matrix ). Es wäre schön, veralteten Code aus dem Debugging zu entfernen. Verhält sich das auf Ihrem System?

>>> import numpy as np
>>> A = np.array([[1.0], [3.0]])
>>> B = np.array([[2.0, 3.0]])
>>> ret = np.dot(A, B)

Wie wäre es mit

>>> import numpy as np
>>> A = np.array([[1.0], [3.0]])
>>> B = np.array([[2.0, 3.0]])
>>> ret = np.matmul(A, B)

Ich gehe davon aus, dass dies auch mit regulären Arrays abstürzt (anstelle von np.matrix ). Es wäre schön, veralteten Code aus dem Debugging zu entfernen. Verhält sich das auf Ihrem System?

>>> import numpy as np
>>> A = np.array([[1.0], [3.0]])
>>> B = np.array([[2.0, 3.0]])
>>> ret = np.dot(A, B)

Crachesh mit "Illegale Anweisung (Core Dumped)"

>>> import numpy as np
>>> A = np.array([[1.0], [3.0]])
>>> B = np.array([[2.0, 3.0]])
>>> ret = np.matmul(A, B)

Gibt:

>>> ret
array([[2., 3.],
       [6., 9.]])

@prokulski wie hast du openblas installiert? Welche Version benutzt du? Wenn Sie das Github-Repository überprüfen, können Sie festlegen, welche Version sich auf welche Weise verhalten soll.

openblas wurde automatisch installiert (als Abhängigkeit von etwas). Ich habe versucht, es zu entfernen und erneut zu installieren (über apt install) - hat nicht geholfen

Dies beantwortet die Frage nach der Versionsnummer immer noch nicht.

Sie haben das System dahingehend geändert, wie die Bibliothek den CPU-Typ erkennt. Wenden Sie sich besser direkt an sie, da numpy nur die Bibliothek verwendet. Siehe zB mein Problem https://github.com/xianyi/OpenBLAS/issues/2067 als Referenz.

$ apt list *blas* | grep installed
libblas-dev/bionic,now 3.7.1-4ubuntu1 amd64 [installed,automatic]
libblas3/bionic,now 3.7.1-4ubuntu1 amd64 [installed,automatic]
libgslcblas0/bionic,now 2.4+dfsg-6 amd64 [installed,automatic]

Ich habe libopenblas-dev installiert und jetzt ist es:

$ apt list *blas* | grep installed
libblas-dev/bionic,now 3.7.1-4ubuntu1 amd64 [installed,automatic]
libblas3/bionic,now 3.7.1-4ubuntu1 amd64 [installed,automatic]
libgslcblas0/bionic,now 2.4+dfsg-6 amd64 [installed,automatic]
libopenblas-base/bionic,now 0.2.20+ds-4 amd64 [installed,automatic]
libopenblas-dev/bionic,now 0.2.20+ds-4 amd64 [installed]

Python:

$ python
Python 3.6.8 (default, Oct  9 2019, 14:04:01)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> A = np.matrix([[1.0], [3.0]])
>>> B = np.matrix([[2.0, 3.0]])
>>> ret = np.dot(A, B)
Illegal instruction (core dumped)

Sie können versuchen, OPENBLAS_CORETYPE für die CPU des Hostsystems festzulegen. Die Zahl, die Sie mit pip install vom PyPI erhalten, enthält OpenBLAS 0.3.7, das einen Fix dafür enthalten sollte. Wenn Sie pip install und keine virtuelle Umgebung verwenden, müssen Sie pip install --upgrade --user numpy , um Konflikte mit der Python Ihres Systems zu vermeiden.

Um die OpenBLAS-Version zu bestimmen, können Sie diesen Code verwenden, der die Version für OpenBLAS 0.3.5 und höher meldet

    import numpy
    import ctypes

    dll = ctypes.CDLL(numpy.core._multiarray_umath.__file__)
    get_config = dll.openblas_get_config
    get_config.restype=ctypes.c_char_p
    res = get_config()
    print('OpenBLAS get_config returned', str(res))

@mattip Ihr Code gibt "OpenBLAS get_config zurückgegeben b'OpenBLAS 0.3.7 DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS = 64 '"

Das Setzen von OPENBLAS_CORETYPE auf Haswell (Kleinbuchstaben, Großbuchstaben, was auch immer) hilft nicht - ich habe es früher versucht.

Ich denke, das Problem liegt in der virtuellen KVM-Maschine und der schlechten CPU-Erkennung in Blas. Seltsam, dass einige Tage zuvor alles in Ordnung war ...

Ich denke, Haswell ist der falsche Wert für Sie, aber eine schnelle Google-Suche liefert keine guten Antworten, um die Host-CPU einmal in einer virtuellen Maschine zu erkennen.

Ich denke, Haswell ist der falsche Wert für Sie, aber eine schnelle Google-Suche liefert keine guten Antworten, um die Host-CPU einmal in einer virtuellen Maschine zu erkennen.

Ja. Skylake wäre besser (wenn Sie cpuinfo sehen), hilft aber auch nicht. Ich stecke fest.
https://github.com/numpy/numpy/milestone/69 gibt Hoffnung;)

Versuchen Sie diese als OpenBLAS-Kernel-Spezifizierer. Funktioniert einer von ihnen?

export OPENBLAS_CORETYPE=prescott

und Dunnington, Penryn, Core2, Nehalem, Sandybridge

Jeder stirbt.

Ermöglicht KVM das Einstellen des CPU-Typs? Wurde es kürzlich aktualisiert?

Fügen Sie Folgendes hinzu, um zu bestätigen, dass die Einstellung des Kerns ordnungsgemäß funktioniert:

export OPENBLAS_VERBOSE=2
export OPENBLAS_CORETYPE=prescott
python -c 'import numpy as np; A = np.array([[1.0], [3.0]]); B = np.array([[2.0, 3.0]]); print(np.dot(A, B))'

Ich bekomme:

Core: Prescott
[[2. 3.]
 [6. 9.]]

Der Support sagte, dass sich beim letzten Mal nichts an den Prozessoren geändert habe.

Ich habe auch Docker Image Jupyter / Tensorflow-Notebook auf diesem Computer gezogen und gestartet, und das in Jupyter ausgeführte Beispiel np.dot () schlägt auf die gleiche Weise fehl. Ich denke, das ist ein Hardwareproblem?

@prokulski Wenn Sie den Code aus dem obigen Kommentar verwenden , erhalten Sie die Ausgabe Core: Prescott vor der illegalen Anweisung?

Da dies spezifisch für Ihre Hardware zu sein scheint, entferne ich es aus dem Meilenstein von 1,18.

Ich habe "Core: Presscot" und dann Matrix 2x2 und KEINE illegale Anweisung.

Ohne die Zeile "export OPENBLAS_CORETYPE = prescott" gibt es eine illegale Anweisung und keine Matrix.

Es scheint, dass die Routine zum Erkennen Ihrer CPU in OpenBLAS von Ihrer KVM verwirrt wird. Könnten Sie es auf dem OpenBLAS Issue Tracker melden, damit sie herausfinden können, was los ist?

Sie können OpenBLAS wahrscheinlich helfen, indem Sie alle oben aufgeführten Kerntypen durchlaufen und herausfinden, welche abstürzen.

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen

Verwandte Themen

dmvianna picture dmvianna  ·  4Kommentare

marcocaccin picture marcocaccin  ·  4Kommentare

dcsaba89 picture dcsaba89  ·  3Kommentare

Kreol64 picture Kreol64  ·  3Kommentare

Foadsf picture Foadsf  ·  3Kommentare