You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Errors when using OpenBLAS through NumPy on Windows 10 2004 #2709
This issue only appears on Windows 10 2004 (19041). It does not appear on Windows 10 1909 (18363).
On a fresh install of NumPy from pip on a 2004 machine, e.g,
pip install numpy ipython
open ipython and enter
import numpy as np
a = np.arange(13 * 13, dtype=np.float64)
a.shape = (13, 13)
a = a % 17
va, ve = np.linalg.eig(a)
This produces an error:
** On entry to DGEBAL parameter number 3 had an illegal value
** On entry to DGEHRD parameter number 2 had an illegal value
** On entry to DORGHR DORGQR parameter number 2 had an illegal value
** On entry to DHSEQR parameter number 4 had an illegal value
---------------------------------------------------------------------------
LinAlgError Traceback (most recent call last)
<ipython-input-1-bad305f0dfc7> in <module>
3 a.shape = (13, 13)
4 a = a % 17
----> 5 va, ve = np.linalg.eig(a)
<__array_function__ internals> in eig(*args, **kwargs)
c:\anaconda\envs\py-pip\lib\site-packages\numpy\linalg\linalg.py in eig(a)
1322 _raise_linalgerror_eigenvalues_nonconvergence)
1323 signature = 'D->DD' if isComplexType(t) else 'd->DD'
-> 1324 w, vt = _umath_linalg.eig(a, signature=signature, extobj=extobj)
1325
1326 if not isComplexType(t) and all(w.imag == 0.0):
c:\anaconda\envs\py-pip\lib\site-packages\numpy\linalg\linalg.py in _raise_linalgerror_eigenvalues_nonconvergence(err, flag)
92
93 def _raise_linalgerror_eigenvalues_nonconvergence(err, flag):
---> 94 raise LinAlgError("Eigenvalues did not converge")
95
96 def _raise_linalgerror_svd_nonconvergence(err, flag):
LinAlgError: Eigenvalues did not converge
What makes me suspect that it is OpenBLAS related is:
It does not happen when using MKL.
It does not happen when using LAPACK-lite that ships with NumPy and is used as a fallback.
On the other hand, it may likely be a Windows bug since:
It does not occur before 2004.
It does not occur when using 32-bit Python on the same system.
It does not occur when running Pythin in WSL on the same machine whether using WSL1, which runs Linux binaries directly on Windows, or WSL2, which runs them in a hypervisor.
While I agree that it looks "OpenBLAS related", I am not yet convinced it is a bug in OpenBLAS itself, particularly if it only happens with/after the Win10 update. The error messages look as if argument passing from C (BLAS) to FORTRAN (LAPACK) functions took a hit.
Perhaps it would make sense to try and build OpenBLAS on a Win10-2004 system (assuming that your pip install just pulled a precompiled binary). Btw it might also be relevant if this affects only particular cpu generations.
The executables in test (if you have them) are at least fortran files calling into C routines, but the lapack-test is currently not available in the cmake build. I'll see if it is sufficient to add its subdirectory to the main CMakeLists.txt but I suspect some things may need adjusting compared to the stock cmake support in Reference-LAPACK.
Indeed pip will install binary by default.
It needs parameter --no-binary :all: to force compilation of all module libraries.
The illegal value parameters are all integers. This might mean that LAPACK and BLAS has different idea of integer sizes. Could you copy numpy directory from working version and test again?It just looks as broken wheel package pulled from pypi.
I tried the nightly from 5/7/20 but this also failed. It has a different version than 1.19 although it isn't obvious how it differs other than it has a different hash.
@bashtage what would be interesting to compare numpy wheels (' hashes) in pip caches. Looking into archives they include 0.3.9-dev version which is anything from development tree (maybe known broken) between 0.3.9 and 0.3.10.
I think we need to add git tag as once proposed out of fact that downstreams do not stick to the releases.
numpy should know which hash they packaged, most likely it is a snapshot from just a few days before the 0.3.10 release to get the fix for inadvertent use of avx512 on haswell (in dynamic_arch builds created on skx). most likely a red herring when the issue seems so closely tied with a microsoft patch.
NumPy is using head in their latest nightlies and it is still producing the same issues.
Edit: I do think it is more and more likely a Windows bug. It even appears when coretype is set to Prescott. I had planned to reach out to a Microsoft Python advocate to see if I can get any bandwidth beyond reporting it through standard channels. It won't show up in CI for a very long time since most CI instances are using build 17xxx of Windows, while 19041+ is required for the bug to appear.
What is your CPU? Like CPU-Z screenshot would be nice
Should be fixable setting OPENBLAS_CORETYPE= SKYLAKEX/HASWELL/SANDYBRIDGE for AVX512/AVX2/AVX respectively.
On Wed, 29 Jul 2020 at 20:31 Andrew ***@***.***> wrote:
Prescott
What is your CPU? Like CPU-Z screenshot would be nice
Should be fixable setting OPENBLAS_CORETYPE= SKYLAKE/HASWELL/SANDYBRIDGE
for AVX512/AVX2/AVX respectively.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2709 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKTSRK27L4XYLONA5POHADR6B2K3ANCNFSM4OUSA2XQ>
.
@brada, yes, MSVC does not emit MMX or FPU in 64bit mode. But the MS runtime libraries are using FPU code and the use it in an unexpected way, hence the problems. As long as OpenBLAS is using FPU or MMX code itself in Win64 in the gcc builds OpenBLAS must care about this problem.
FCLEX and EMMS instructions are not harmful and costs only some cycles. So why not add them in the right place?
Further to this, do we know that routines using only MMX are definitely affected by this DLL bug as well, or is this just an assumption based on them sharing the same registers ? (Thinking MMX is a bit more likely to still be in use than x87, so there should be more users and programs affected by the bug)
@martin-frbg, I'm not a assembler guru. My idee what happens with this crazy issue are described here: #2709 (comment) and are the results of reflection after scamming numerous documents, stackoverflow/blog contributions. A huge time sink btw. EDIT: we should file MS an invoice :-(
I have an idea about why MMX is not affected: Maybe because MMX uses the registers as is and not as a circulating stack. But this is speculation. So from the MMX point of view the registers can be simply used and erroneous values will be overwritten.
The documentation says:
The EMMS instruction must be used to clear the MMX technology state at the end of all MMX technology procedures or subroutines and before calling other procedures or subroutines that may execute x87 floating-point instructions. If a floating-point instruction loads one of the registers in the x87 FPU data register stack before the x87 FPU tag word has been reset by the EMMS instruction, an x87 floating-point register stack overflow can occur that will result in an x87 floating-point exception or incorrect result.
EMMS operation is the same in non-64-bit modes and 64-bit mode.
I have drawn two conclusions from that:
Before using the FPU EMMS can heal the the FPU state.
---, yes, MSVC does not emit MMX or FPU in 64bit mode. But the MS runtime libraries are using FPU code and the use it in an unexpected way, hence the problems. As long as OpenBLAS is using FPU or MMX code itself in Win64 in the gcc builds OpenBLAS must care about this problem.
FCLEX and EMMS instructions are not harmful and costs only some cycles. So why not add them in the right place?
It looks like somehow the stuf that applied to userspace WDM (printer drivers) that mmx state is corrupted over context switch, came to generic applications too. Would be interesting to see if windows vista compatibility layer fixes this.
@carlkl think you may be tagging an unrelated user in your replies to brada4 here. @brada4 from your suggestions I am not sure if you have been following this thread...
Commenting on this closed issue to update that in numpy/numpy#17547 I added code to call emms after a call to fmod in windows, so now we have both a belt and suspenders (does that work in English?)
Activity
martin-frbg commentedon Jul 8, 2020
While I agree that it looks "OpenBLAS related", I am not yet convinced it is a bug in OpenBLAS itself, particularly if it only happens with/after the Win10 update. The error messages look as if argument passing from C (BLAS) to FORTRAN (LAPACK) functions took a hit.
Perhaps it would make sense to try and build OpenBLAS on a Win10-2004 system (assuming that your
pip installjust pulled a precompiled binary). Btw it might also be relevant if this affects only particular cpu generations.bashtage commentedon Jul 8, 2020
I ran openblas_utext.exe without any issues. Is there an equivalent to the
lapack-testdirective in the *nix make file?martin-frbg commentedon Jul 8, 2020
The executables in
test(if you have them) are at least fortran files calling into C routines, but the lapack-test is currently not available in the cmake build. I'll see if it is sufficient to add its subdirectory to the main CMakeLists.txt but I suspect some things may need adjusting compared to the stock cmake support in Reference-LAPACK.brada4 commentedon Jul 9, 2020
Indeed pip will install binary by default.
It needs parameter
--no-binary :all:to force compilation of all module libraries.The illegal value parameters are all integers. This might mean that LAPACK and BLAS has different idea of integer sizes. Could you copy numpy directory from working version and test again?It just looks as broken wheel package pulled from pypi.
bashtage commentedon Jul 9, 2020
I tried the nightly from 5/7/20 but this also failed. It has a different version than 1.19 although it isn't obvious how it differs other than it has a different hash.
I'll try to build myself in the next few days.
brada4 commentedon Jul 9, 2020
It is not directly made by OpenBLAS, could you point to hashes you talk about so that we can have a look at package content?
https://pypi.org/project/numpy/#files
brada4 commentedon Jul 10, 2020
@bashtage what would be interesting to compare numpy wheels (' hashes) in pip caches. Looking into archives they include 0.3.9-dev version which is anything from development tree (maybe known broken) between 0.3.9 and 0.3.10.
I think we need to add git tag as once proposed out of fact that downstreams do not stick to the releases.
bashtage commentedon Jul 10, 2020
From NumPy 1.19.0:
libopenblas.NOIJJG62EMASZI6NYURL6JBKM4EVBGM7.gfortran-win_amd64.dll
stringsindicates this is 3.9From NumPy nightly 5/7/2020:
libopenblas.VN4TFHCG6GCB7E53NOJHJWQ4PL7VXRV3.gfortran-win_amd64
stringsindicates this is 3.10[It is my assumption that the large string is a hash]
martin-frbg commentedon Jul 10, 2020
numpy should know which hash they packaged, most likely it is a snapshot from just a few days before the 0.3.10 release to get the fix for inadvertent use of avx512 on haswell (in dynamic_arch builds created on skx). most likely a red herring when the issue seems so closely tied with a microsoft patch.
brada4 commentedon Jul 10, 2020
Is the hash on the working system matching any of these two?
martin-frbg commentedon Jul 23, 2020
There is a (small) chance that #2729 may have fixed this (inconsistent declarations of the size of the GEMM buffer in DYNAMIC_ARCH builds)
martin-frbg commentedon Jul 29, 2020
@bashtage Any news on this ?
bashtage commentedon Jul 29, 2020
NumPy is using head in their latest nightlies and it is still producing the same issues.
Edit: I do think it is more and more likely a Windows bug. It even appears when coretype is set to Prescott. I had planned to reach out to a Microsoft Python advocate to see if I can get any bandwidth beyond reporting it through standard channels. It won't show up in CI for a very long time since most CI instances are using build 17xxx of Windows, while 19041+ is required for the bug to appear.
brada4 commentedon Jul 29, 2020
What is your CPU? Like CPU-Z screenshot would be nice
Should be fixable setting OPENBLAS_CORETYPE= SKYLAKEX/HASWELL/SANDYBRIDGE for AVX512/AVX2/AVX respectively.
bashtage commentedon Jul 29, 2020
55 remaining items
carlkl commentedon Oct 8, 2020
@brada, yes, MSVC does not emit MMX or FPU in 64bit mode. But the MS runtime libraries are using FPU code and the use it in an unexpected way, hence the problems. As long as OpenBLAS is using FPU or MMX code itself in Win64 in the gcc builds OpenBLAS must care about this problem.
FCLEX and EMMS instructions are not harmful and costs only some cycles. So why not add them in the right place?
martin-frbg commentedon Oct 8, 2020
Do we know by know that the FCLEX (or FNCLEX) plut EMMS combo is sufficient to clear this sorry state ?
carlkl commentedon Oct 8, 2020
I will try it as soon as I can. I have to setup my development machine first.
martin-frbg commentedon Oct 8, 2020
Further to this, do we know that routines using only MMX are definitely affected by this DLL bug as well, or is this just an assumption based on them sharing the same registers ? (Thinking MMX is a bit more likely to still be in use than x87, so there should be more users and programs affected by the bug)
carlkl commentedon Oct 8, 2020
I will try it as soon as I can. I have to setup my development machine first.
carlkl commentedon Oct 8, 2020
@martin-frbg, I'm not a assembler guru. My idee what happens with this crazy issue are described here: #2709 (comment) and are the results of reflection after scamming numerous documents, stackoverflow/blog contributions. A huge time sink btw. EDIT: we should file MS an invoice :-(
I have an idea about why MMX is not affected: Maybe because MMX uses the registers as is and not as a circulating stack. But this is speculation. So from the MMX point of view the registers can be simply used and erroneous values will be overwritten.
The documentation says:
The EMMS instruction must be used to clear the MMX technology state at the end of all MMX technology procedures or subroutines and before calling other procedures or subroutines that may execute x87 floating-point instructions. If a floating-point instruction loads one of the registers in the x87 FPU data register stack before the x87 FPU tag word has been reset by the EMMS instruction, an x87 floating-point register stack overflow can occur that will result in an x87 floating-point exception or incorrect result.
EMMS operation is the same in non-64-bit modes and 64-bit mode.
I have drawn two conclusions from that:
But again: I'm not an assembler guru.
brada4 commentedon Oct 9, 2020
It looks like somehow the stuf that applied to userspace WDM (printer drivers) that mmx state is corrupted over context switch, came to generic applications too. Would be interesting to see if windows vista compatibility layer fixes this.
carlkl commentedon Oct 9, 2020
@brada, the error has been localized see numpy/numpy#16744 (comment). It is caused by the use of fmod from ucrtbase.dll (10.0.19041.488). See https://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html and https://developercommunity.visualstudio.com/content/problem/1208774/fpu-exception-in-fmod0-x-in-windows-10-version-200.html.
martin-frbg commentedon Oct 9, 2020
@carlkl think you may be tagging an unrelated user in your replies to brada4 here. @brada4 from your suggestions I am not sure if you have been following this thread...
carlkl commentedon Oct 9, 2020
@martin-frbg, I think you are right.
mattip commentedon Oct 13, 2020
Commenting on this closed issue to update that in numpy/numpy#17547 I added code to call
emmsafter a call to fmod in windows, so now we have both a belt and suspenders (does that work in English?)bashtage commentedon Oct 13, 2020
@mattip Belt and bracers</uk translation>
📦 Unpin Numpy Version
Update Numpy minimum version