ํ
์คํธ ์คํจ :
FAILED .... libteststest_regression.py::TestRegression::test_polyfit_build-numpy.linalg.LinAlgError : SVD๊ฐ ์คํจํ์ต๋๋ค ...
FAILED .... linalgteststest_regression.py::TestRegression::test_eig_build-numpy.linalg.LinAlgError : ๊ณ ์ ๊ฐ ...
FAILED .... mateststest_extras.py::TestPolynomial::test_polyfit-numpy.linalg.LinAlgError : SVD๊ฐ i ...
์์ธ ์ฌํญ :
err = 'invalid value', flag = 8
def _raise_linalgerror_lstsq(err, flag):
> raise LinAlgError("SVD did not converge in Linear Least Squares")
E numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares
err = 'invalid value'
flag = 8
๊ณผ
err = 'invalid value', flag = 8
def _raise_linalgerror_eigenvalues_nonconvergence(err, flag):
> raise LinAlgError("Eigenvalues did not converge")
E numpy.linalg.LinAlgError: Eigenvalues did not converge
err = 'invalid value'
flag = 8
์ทจํ ์กฐ์น :
pip install pytest
pip install numpy
pip install hypothesis
์ ์ฅ์์ ํ ์คํธ์์ ์คํํ ๋ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค.
numpy ๋ฒ์ 1.19.0
์ข ์์ฑ์ด ๋๋ฝ ๋์์ต๋๊น? ์๋๋ฉด ๊ทธ๋ฅ Windows๊ฐ ๊ดด๋กญ ํ๊ณ ์์ต๋๊น?
ํธ์ง : ๋น์ ์ ๋ถ๋ช ํ pip๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค. ์ต๊ทผ ๊ณผ๊ฑฐ์ ์ ํ ๋์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๊ณ ์ ๊ฐ ๋ถํด (statsmodels ํ ์คํธ ์คํ ๋งฅ๋ฝ์์)๋ฅผ ์ฌ์ฉํ์ฌ Windows AMD64์์ ์ด์ํ ๊ฒฐ๊ณผ๋ฅผ ์ป์์ต๋๋ค.
์๊ฐ์ด ์๋ค๋ฉด 32 ๋นํธ Python๊ณผ pip๋ฅผ ์ฌ์ฉํด๋ณด๊ณ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋์ง ํ์ธํ์ธ์. 32 ๋นํธ ์ฐฝ์์๋ ๋ณผ ์ ์์ง๋ง 64 ๋นํธ ์ฐฝ์์๋ ๋ฐ๋ณต ํ ์์์์ต๋๋ค.
MKL์ ์ ๊ณตํ๋ conda๋ฅผ ์ฌ์ฉํ๋ฉด ์ค๋ฅ๊ฐ ์์ต๋๋ค.
ํธ์ง : Windows AMD64์์ NumPy 1.18.5๋ฅผ ์ฌ์ฉํ ๋๋ ํ์๋ฉ๋๋ค.
์ต์ Windows 10 ์ ๋ฐ์ดํธ ํ ํ ์คํธ ์คํจ
์ ๋ฐ์ดํธ ์ ์ ํ ์คํธ๊ฐ ์คํจ ํ์ต๋๊น?
@charris ์์, ์ ๋ฐ์ดํธ ์ ์ ํ ์คํธ ์ค์ํธ๊ฐ ํต๊ณผํฉ๋๋ค.
@speixoto ๊ตฌ์ฒด์ ์ผ๋ก ์ด๋ค ์ ๋ฐ์ดํธ์ธ์ง ์๊ณ ์์ต๋๊น? pip-installed wheels์ ๋ํ ๋ด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋๋์ง ํ์ธํ๊ณ ์ถ์ต๋๋ค.
์ ๋ฐ์ดํธ 1809 (10.0.17763)๋ก ์ธํด @bashtage ํ ์คํธ๊ฐ ์คํจํ์ง
1909 ๋ ์๋ ์๋ฌด ์ผ๋ ์ผ์ด๋์ง ์์์ต๋๋ค. 2004 ๋ ๋ถํฐ ์์๋์์ต๋๋ค.
๋๋ ๊ทธ๊ฒ์ด 2004 ๋ ์ด๋ ๊ทธ ์ดํ๋ผ๊ณ 100 % ํ์ ํ์ง ์๋๋ค. 2004 ๋ ์ด ํจ๊ณผ์ ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
FWIW CI (Azure ๋๋ appveyor)์์ ์ด๋ฌํ ์ถฉ๋์ ์ฌํ ํ ์ ์์ง๋ง AMD64 ๋ฐ 2004 ๋ ์ ๋ฐ์ดํธ ์ธ ๋ ์ปดํจํฐ์์ ๋ก์ปฌ๋ก ์ํํฉ๋๋ค.
๋ ์ค ํ ์ฌ๋์ด 32 ๋นํธ Python์์ ๊ฐ์ ธ ์ค๋์ง ํ์ธํ๋ ค๊ณ ํ์ต๋๊น?
2004 ๋ ์ ๋ฐ์ดํธ์ ๋ํด๋ณด๊ณ ๋ ๋ง์ ๋ฌธ์ ๊ฐ์๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ด๊ฒ๋๋ณด๊ณ ํด์ผํ ๊น์?
1909 ๋ฐ 2004์ ์๋ก ์ค์น์์ ๋ค์์ ์คํํ์ต๋๋ค.
pip install numpy scipy pandas pytest cython
git clone https://github.com/statsmodels/statsmodels.git
cd statsmodels
pip install -e . --no-bulid-isolation
pytest statsmodels
1909 ๋ ์๋ ์คํจ๊ฐ ์์ต๋๋ค. 2004 ๋ ์ 30 ๊ฑด์ ์คํจ๋ ๋ชจ๋ ์ ํ ๋์ ํจ์์ ๊ด๋ จ์ด ์์ต๋๋ค.
2004 ๋ ์ ๋๋ฒ๊ฑฐ์์ ํ ์คํธ๋ฅผ ์คํํ์ ๋ ํจ์์ ๋ํ ์ฒซ ๋ฒ์งธ ํธ์ถ์ ์ข ์ข ์๋ชป๋ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ์ง๋ง ๋ค์ ํธ์ถํ๋ฉด ์ฌ๋ฐ๋ฅธ ๊ฒฐ๊ณผ๊ฐ ์์ฑ๋๋ค๋ ๊ฒ์ ์์์ต๋๋ค (๋ฐ๋ณต์ ์ผ๋ก ํธ์ถํด๋ ์ฌ๋ฐ๋ฅธ ๊ฒฐ๊ณผ๊ฐ ์ ์ง๋จ). ์ด๊ฒ์ด ์์ธ์ ์ถ์ธกํ๋ ๋ฐ ์ ์ฉํ ์ ๋ณด์ธ์ง ํ์คํ์ง ์์ต๋๋ค.
์ด์ ๋ฒ์ ์ NumPy์๋ ๋ฌธ์ ๊ฐ ์์ต๋๊น? ๋๋ ๋น์ ์ด 1.19.0์ ์คํํ๊ณ ์๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.
pip + 1.18.4 ๋ฐ scipy 1.4.1์ ์ฌ์ฉํ๋ฉด ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ด๊ฒ์ ์ ๋ง ์ผ๋ฐ์ ์ ๋๋ค.
ERROR statsmodels/graphics/tests/test_gofplots.py::TestProbPlotLongely::test_ppplot - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/graphics/tests/test_gofplots.py::TestProbPlotLongely::test_qqplot_other_array - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/graphics/tests/test_gofplots.py::TestProbPlotLongely::test_probplot - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/graphics/tests/test_regressionplots.py::TestPlot::test_plot_leverage_resid2 - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/regression/tests/test_regression.py::TestOLS::test_params - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/regression/tests/test_regression.py::TestOLS::test_scale - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/regression/tests/test_regression.py::TestOLS::test_ess - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/regression/tests/test_regression.py::TestOLS::test_mse_total - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/regression/tests/test_regression.py::TestOLS::test_bic - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/regression/tests/test_regression.py::TestOLS::test_norm_resids - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/regression/tests/test_regression.py::TestOLS::test_HC2_errors - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/regression/tests/test_regression.py::TestOLS::test_missing - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/regression/tests/test_regression.py::TestOLS::test_norm_resid_zero_variance - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/tsa/tests/test_stattools.py::TestADFConstant::test_teststat - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/tsa/tests/test_stattools.py::TestADFConstant::test_pvalue - numpy.linalg.LinAlgError: SVD did not converge
ERROR statsmodels/tsa/tests/test_stattools.py::TestADFConstant::test_critvalues - numpy.linalg.LinAlgError: SVD did not converge
1.18.5 + MKL์ ์ฌ์ฉํ์ฌ ์คํํ ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ง ์์ต๋๋ค. ์ด๊ฒ์ด OpenBLAS ๋ฒ๊ทธ์ธ์ง Windows ๋ฒ๊ทธ์ธ์ง ๋งํ๊ธฐ๋ ์ด๋ ต์ต๋๋ค. ์๋ง๋ ํ์ ์ผ ๊ฒ์ ๋๋ค. ๊ทธ๋ฌ๋ ์ ๊ทผํ๊ธฐ๊ฐ ์ ๋ง ์ด๋ ต๊ณ ์ง๋จ์ ์ ์์ค ๋๋ฒ๊น ์ ๋ํ ์ ๋ฅ๋ ฅ์ ๋์ด์๋ ๊ฒ์ ๋๋ค.
๋์ผํ ๋ฌผ๋ฆฌ์ ์ปดํจํฐ์์ pip ํจํค์ง๋ฅผ ์ฌ์ฉํ์ฌ Ubuntu์์ ์คํํ ๋ ์ค๋ฅ๊ฐ ํ์๋์ง ์์ต๋๋ค.
์ด๊ฒ์ ๊ฐ์ฅ ์ด์ํ ํ๋์ ๋๋ค. ์ฒซ ๋ฒ์งธ ํธ์ถ์์ ์คํจํ๊ณ ๋ ๋ฒ์งธ ๋ฐ ํ์ ํธ์ถ์์ ์๋ํฉ๋๋ค. ๋ ๋ค๋ฅธ ์ดํดํ๊ธฐ ์ด๋ ค์ด ๋์์ ์คํจํ ํ ์คํธ๋ฅผ ๊ฒฉ๋ฆฌํ์ฌ ์คํํ๋ฉด ์ค๋ฅ๊ฐ ํ์๋์ง ์๋๋ค๋ ๊ฒ์ ๋๋ค.
๋ง์ง๋ง ์ ๋ฐ์ดํธ : ์ต์ ํ ๋ BLAS์์ด NumPy์ ์์ค ๋น๋๋ฅผ ์ฌ์ฉํ์ฌ ํ ์คํธํ๋ฉด ๋์ผํ ์ธํธ๊ฐ ์๋์ง๋ง ์ฌ์ ํ ์ค๋ฅ๊ฐ ํ์๋ฉ๋๋ค.
OpenBLAS ๊ฐ๋ฐ์๋ฅผ ํํ ๊ฐ์น๊ฐ์์ ๊ฒ์ ๋๋ค. float32์์ float64๋งํผ ์์ฃผ ๋ฐ์ํฉ๋๊น?
NumPy 1.19.0, python -c "import numpy;numpy.test('full')"
์ ์ ์ฒด ํ
์คํธ๋ฅผ ์คํํ ๋ ์์ ๋์ผํ ์ค๋ฅ๊ฐ ํ์๋ฉ๋๋ค.
FAILED Python/Python38/Lib/site-packages/numpy/lib/tests/test_regression.py::TestRegression::test_polyfit_build - numpy.linalg.LinAlgError: SVD did not conv...
FAILED Python/Python38/Lib/site-packages/numpy/linalg/tests/test_regression.py::TestRegression::test_eig_build - numpy.linalg.LinAlgError: Eigenvalues did n...
FAILED Python/Python38/Lib/site-packages/numpy/ma/tests/test_extras.py::TestPolynomial::test_polyfit - numpy.linalg.LinAlgError: SVD did not converge in Lin...
๋๋ ๋น์ ์ด ๋ ์ ์ ์ผ๋ก ํ ์คํธ๋ฅผ ์คํํ๋ค๋ฉด ๊ทธ๊ฒ์ ๋ ์ด์ํ ํ๋์ ์๋ฏธํ๊ธฐ ์ํด ์ฃผ๋ณ์ ํํ๋ ๊ฒ์ ์ฌ๋ฐ๋ฅด๊ฒ ๊ธฐ์ตํ๋ค๋ฉด ํต๊ณผํด์ผํ๋ค๊ณ ์๊ฐํฉ๋๋ค.
๋ค์๊ณผ ๊ฐ์ ๋ฐฉ๋ฒ์ ์๋ ์ ์ผํ ๋ฐฉ๋ฒ์ผ๋ก Microsoft์ ์ ์ถํ์ต๋๋ค.
๋ค๋ฅธ ์ฌ๋์ด ๊ฒ์์ ํตํด ์ฐพ์ ๊ฒฝ์ฐ ๊ฒ์ :
2004 ๋ ์์ด ๋ฌธ์ ๊ฐ ํด๊ฒฐ ๋ ๋๊น์ง Windows ์ฌ์ฉ์๋ Conda / MKL์ ์ฌ์ฉํด์ผํฉ๋๋ค.
๋ค์์ ์์ ์ฌํ ์์ ๋๋ค.
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)
์์ฐ
** 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-11-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
LAPACK์ 0 ๋๋ 1์์ ๊ณ์ฐํฉ๋๊น? ๋ชจ๋ ์๋ชป๋ ๊ฐ์ ์ ์๋ก ๋ํ๋ฉ๋๋ค.
DGEBAL
DGEHRD
DORGHR
DHSEQR
OpenBlas ๋ฌธ์ (๋๋ 2004 ๋ ๊ณผ OpenBLAS ์ฌ์ด์ ๋ฌธ์ )์ฒ๋ผ ๋ณด์ ๋๋ค. ๋ด ์์ฝ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
NumPy ๋ง python -c "import numpy;numpy.test('full')"
statsmodels ํ
์คํธ pytest statsmodels
scipy.linalg
๋ฃจํด๊ณผ ๊ด๋ จ๋ ๊ฒ๋ณด๋ค ๋ ์ ์ต๋๋ค.2004 ๋ ์ ๋ฌด์์ด ๋ฐ๋ ์๋์ง ๋ฐฐ์ฐ๋ฉด ์ข์ ๊ฒ์ ๋๋ค. ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ปดํ์ผ / ๋งํฌ ํ ๋ ๋ค๋ฅธ ํ๋๊ทธ๊ฐ ํ์ํ ๊น์?
_OpenBLAS ๋ฒ๊ทธ ์ธ ๊ฒฝ์ฐ Windows ๊ธฐ๋ฐ CI๊ฐ ๋น๋ 19041 (์ผ๋ช Windows 10 2004) ์ด์์ ์ฌ์ฉํ์ง ์๊ธฐ ๋๋ฌธ์ ๋ฐ๊ฒฌ๋์ง ์์์ ๊ฒ์ ๋๋ค.
๋ถ๋ช ํ ๋งํด์, ์ด๋ฌํ ๋ณด๊ณ ์ ์ค WSL๊ณผ ๊ด๋ จ๋ ๋ณด๊ณ ์๊ฐ ์๋ค๋ ๊ฒ์ด ์ฌ์ค์ ๋๊น?
์๋์. conda ์ ๊ณต python.exe
๋๋ python.org ์ ๊ณต python.exe
ํ๊ฒฝ ๋ณ์ OPENBLAS_CORETYPE=Haswell
๋๋ OPENBLAS_CORETYPE=NEHALEM
๊ฐ ๋ช
์ ์ ์ผ๋ก ์ค์ ๋์ด ์์ผ๋ฉด ํ
์คํธ๊ฐ ์คํจํฉ๋๊น?
Atom, SandyBridge, Haswell, Prescott ๋ฐ Nehalem์ ์ฌ์ฉํด ๋ณด์์ต๋๋ค. ๋ชจ๋ ๋์ผํ ๊ฒฐ๊ณผ๋ฅผ ์ป์์ต๋๋ค.
๊ฐ์ฅ ์ด์ํ ์ ์
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 will raise, so manually run the next line
va, ve = np.linalg.eig(a)
eig
๋ํ ๋ ๋ฒ์งธ (๋ฐ ์ถ๊ฐ) ํธ์ถ์ด ์ฑ๊ณตํฉ๋๋ค.
SciPy์๋ ๋น์ทํ ์ค๋ฅ๊ฐ ์์ต๋๋ค.
import numpy as np
import scipy.linalg
a = np.arange(13 * 13, dtype=np.float64)
a.shape = (13, 13)
a = a % 17
va, ve = scipy.linalg.eig(a)
์ ๊ธฐํ๋
** 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
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-58-8dfe8125dfe3> in <module>
4 a.shape = (13, 13)
5 a = a % 17
----> 6 va, ve = scipy.linalg.eig(a)
c:\anaconda\envs\py-pip\lib\site-packages\scipy\linalg\decomp.py in eig(a, b, left, right, overwrite_a, overwrite_b, check_finite, homogeneous_eigvals)
245 w = _make_eigvals(w, None, homogeneous_eigvals)
246
--> 247 _check_info(info, 'eig algorithm (geev)',
248 positive='did not converge (only eigenvalues '
249 'with order >= %d have converged)')
c:\anaconda\envs\py-pip\lib\site-packages\scipy\linalg\decomp.py in _check_info(info, driver, positive)
1348 """Check info return value."""
1349 if info < 0:
-> 1350 raise ValueError('illegal value in argument %d of internal %s'
1351 % (-info, driver))
1352 if info > 0 and positive:
ValueError: illegal value in argument 4 of internal eig algorithm (geev)
๋ง์ง๋ง ๋ฉ๋ชจ๋ np.complex128
๋ก ์ ํํ๋ฉด ์ธ์๋์ง๋ง np.float32
๋๋ np.complex64
ํ๋ฉด ๋ฌธ์ ์์ด ์๋ํฉ๋๋ค.
๊ธด ์ ์๋ก ์ปดํ์ผ ๋ ์ฝ๋์ Python ๋ถ๋ถ์ด์ง๋ง ํฌํธ๋ (LAPACK) ๋ถ๋ถ์์ INTERFACE64 = 1์์ด ๋น๋ ๋ OpenBLAS?
(์ด๊ฒ์ ์ฒซ ๋ฒ์งธ ํธ์ถ์ด ์คํจํ ์ด์ ๋ฅผ ์ค๋ช
ํ์ง ์์ง๋ง ํ์ ํธ์ถ์ด ์ฑ๊ณตํ๋ ์ด์ ์ 19041 ์
๋ฐ์ดํธ ์ด์ ์ ์๋ ํ ์ด์ ๋ฅผ ์ค๋ช
ํ์ง ์์ต๋๋ค.)
Windows 10 ์ฌ์ฉ์๋ Microsoft์ ํผ๋๋ฐฑ ํ๋ธ์์์ด ๋ฌธ์ ๋ฅผ ์ฐฌ์ฑ ํ ์ ์์ต๋๋ค.
@bashtage ์ ์์ฒญ์ ๋ฐ๋ผ ์ฝ๋๋ฅผ ์กฐ๊ธ ํํค ์ณค์ผ๋ฉฐ ๋ถ๋ ์์์ ์ํ์ ์ผ๋ถ ์ธก๋ฉด์ด
np.complex128๋ก ๋ณํํ๋ฉด ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ง๋ง np.float32 ๋๋ np.complex64๋ก ๋ณํํ๋ฉด ๋ฌธ์ ์์ด ์๋ํฉ๋๋ค.
์ฒซ ๋ฒ์งธ ๊ฒฝ๊ณ ๋ฉ์์ง (์ฑ๊ณตํ์ ๋ ๋ํ๋์ง ์๋ ๊ฒ ๊ฐ์) "DGEBAL ๋งค๊ฐ ๋ณ์ ๋ฒํธ 3์ ์๋ชป๋ ๊ฐ์ด ์์ต๋๋ค."๋์ด ์กฐ๊ฑด์ผ๋ก ์ธํด ๋ฐ์ํฉ๋๋ค. https://github.com/xianyi/OpenBLAS/blob/ce3651516f12079f3ca2418aa85b9ad571c3a391/lapack -netlib / SRC / dgebal.f # L336 ์ด๋ NaN์ผ๋ก ์ด๋ํ๋ ์ด์ ๊ณ์ฐ์ ์ํด ๋ฐ์ํ ์ ์์ต๋๋ค.
์ฌํ ๋จ๊ณ๋ฅผ ๊ฐ์ง๊ณ ๋๋ฉด์ mod๋ฅผ float32๋ก "์์ "ํ๋ ๊ฒ์ ๋ฐ๊ฒฌํ์ต๋๋ค.
import numpy as np
a = np.arange(13 * 13, dtype=np.float64)
a.shape = (13, 13)
a = (a.astype(np.float32) % 17).astype(np.float64) # <-- only line changed
va, ve = np.linalg.eig(a)
๊ทธ๋์ ์ ์๊ฐ์๋ ์ฝ๋ ๊ฒฝ๋ก์ ์ํ๋ฅผ ์ฌ๋ฐ๋ฅด๊ฒ ์ฌ์ค์ ํ๋ ๊ฒ์ด ์์ง๋ง ๊ทธ๊ฒ์ด ๋ฌด์์ธ์ง ํ์คํ์ง ์์ต๋๋ค. numpy์ ๋ด๋ถ์ ๋ ์ต์ํ ๋๊ตฐ๊ฐ๊ฐ ๊ทธ๊ฒ์ด ์ด๋์ ์ผ์ด๋ ์ ์๋์ง ์ ์ ์๊ธฐ๋ฅผ ๋ฐ๋๋๋ค.
Kind of๋ WIndows์์ mingw๋ก ๋ณด์๋ ์ค๋๋ ๋ฒ๊ทธ๋ฅผ ์๊ธฐ์ํต๋๋ค. ๋ถ๋ ์์์ ๋ ์ง์คํฐ ๊ตฌ์ฑ์ด ์์
์ ์ค๋ ๋์ ์ํด ์์๋์ง ์์ ๋น์ ๊ท ํญ๋ชฉ์ด 0์ผ๋ก ํ๋ฌ์๋์ง ์๊ณ ํ์ ๊ณ์ฐ์ ์๋ง์ผ๋ก ๋ง๋๋ ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค.
์ด๊ฒ์ด ํ์ฌ ํ๋์จ์ด์ ํ์ฌ Windows์ ์ด๋ค ์ ์ผ๋ก๋ ๊ด๋ จ์ด ์๋์ง ํ์คํ์ง ์์ง๋ง
OpenBLAS ๋น๋๋ CONSISTENT_FPCSR = 1๋ก ์๋ฃ๋์์ต๋๋ค (๋๋ ํด๋น ๋น๋ ์ต์
์ ์ถ๊ฐํ๋ ๊ฒ์ด ๋์์ด๋๋ ๊ฒฝ์ฐ).
@mattip OpenBLAS ๋น๋์์ CONSISTENT_FPCSR = 1์ธ์ง ์์ญ๋๊น?
์ํ๊น๊ฒ๋ ๋ค์๊ณผ ๊ฐ์ด ๋ณด์ ๋๋ค.
๊ธ์, ์ ์ด๋ ์ด๊ฒ์ ๊ธธ์ ๋ฒ์ด๋ฌ์ต๋๋ค. ์ด์จ๋ ์ฐ๊ฒฐ์ ์๋นํ ๋จผ ๊ฒ์ฒ๋ผ ๋ณด์์ต๋๋ค.
์๋
ํ์ธ์! ๋๋ ํ๋์ ๋น์ทํ ๋ฌธ์ ๋ฅผ ๊ฒช์ด ์์ผ๋ฉฐ ๋ชจ๋ ํ
์คํธ๋ Windows 10 (2004)๊ณผ OpenBlas ์ฌ์ด์ ๋ญ๊ฐ ์ด์ํ ์ ์ ์ง์ ํฉ๋๋ค. ์ ๋ ๋ณดํต 3 ๋์ PC (2 ๋์ Windows 10 ์ํฌ ์คํ
์ด์
๊ณผ ๊ตฌํ Windows 7 ๋
ธํธ๋ถ)์์ ํ๋ก๊ทธ๋จ์ ์คํํฉ๋๋ค. ๋ด Python ์คํฌ๋ฆฝํธ๋ 2 ๊ฐ์ ์ํฌ ์คํ
์ด์
์ Windows 10 ๋ฒ์ 2004๋ก ์
๊ทธ๋ ์ด๋ ํ ๋ linalg ๋ฐ svd () ์๋ ด๊ณผ ๊ด๋ จ๋ ์ค๋ฅ๋ก ์ค์๋ํ๊ธฐ ์์ํ์ต๋๋ค. ์คํฌ๋ฆฝํธ๋ฅผ ์ฒ์ ์คํํ ๋ ์ถฉ๋์ด ๋ฐ์ํ์ง๋ง ๋๋ถ๋ถ์ ๊ฒฝ์ฐ ๋ ๋ฒ์งธ ์๋์์ ์์
ํ์ต๋๋ค (Jupyter ๋
ธํธ๋ถ ์คํ). ์ค๋๋ ๋ฉํฑ ์ฅ๋น๋ ์ค๋ฅ์์ด ๋์ผํ ํ๋ก๊ทธ๋จ์ ๊ณ์ ์คํํ์ต๋๋ค! ๋๋ miniconda, python 3.6์ ๊ฐ์ง๊ณ ์์ผ๋ฉฐ ๋ชจ๋ ํจํค์ง๋ pip๋ฅผ ์ฌ์ฉํ์ฌ ์ค์น๋ฉ๋๋ค (env๋ 3 ๋์ ์ปดํจํฐ์์ ์ ํํ ๋์ผํฉ๋๋ค).
์ค๋์ ํ ๊ธฐ๋ณธ NumPy์ (1.19.0) ์ค์น๋ฅผ ์ ๊ฑฐ์์ NumPy์ + MKL (NumPy์-1.19.1 + MKL-cp36-cp36m-win_amd64.whl) ๋ฒ์ ์ ์ค์น https://www.lfd.uci.edu/ ~ gohlke / pythonlibs /. ์ง๊ธ๊น์ง linalg ๋ฐ svd () ์๋ ด๊ณผ ๊ด๋ จ๋ ์ค๋ฅ๊ฐ ์ฌ๋ผ์ก์ต๋๋ค. ๋ค๋ฅธ ๊ฒ์ ์ฐพ์ผ๋ฉด ์ฌ๊ธฐ๋ก ๋์์๋ณด๊ณ ํ๊ฒ ์ต๋๋ค.
๋ค๋ฆฌ์ค
OpenBLAS dll์ด lib.exe์ VC9 ๋ฒ์ ์ ์ํด ์์ฑ๋๋ ๊ฒ์ด ์ด์ํฉ๋๊น? ์ด๊ฒ์ Python 2.7์์ ์ฌ์ฉ ๋ ๋ฒ์ ์ ๋๋ค. ์ค์ํ์ง ์์ ์๋ ์์ง๋ง VC9๊ฐ ์ด๋์๋ ์ฌ์ฉ๋์ง ์๋๋ค๋ ์ ์ ๊ฐ์ํ ๋ ์ด์ํ๊ฒ ๋๊ปด์ง๋๋ค.
๋๊ตฐ๊ฐ (์๋ง๋ ๋)์ ๋ค์ ๋จ๊ณ๋ ๋จ์ผ ์ค๋ ๋ OpenBLAS ( USE_THREAD=0
)๋ก NumPy ๋ง์คํฐ๋ฅผ ๊ตฌ์ถํ์ฌ ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋๋์ง ํ์ธํ๋ ๊ฒ์
๋๋ค.
์ฑ๊ณตํ์ง ๋ชปํ ๋ช ๊ฐ์ง ์คํ์ ์๋ํ์ต๋๋ค.
USE_THREADS=0
๋นํ์ฑํINTERFACE64=1
<-์ก์ธ์ค ์๋ฐ์ด์๋ NumPy ํ
์คํธ์ SegfaultWin10 ์ค์ ์ผ๋ก LAPACK ํ ์คํธ ์ค์ํธ๋ฅผ ์คํํ ์ ์์ต๋๊น? ๋๋ ์ต๊ทผ์ ๊ทธ๊ฒ์ ์์ฑํ๊ธฐ ์ํด cmake ๋น๋๋ฅผ ์์ ํ๋๋ฐ, ์๋ง๋ numpy๊ฐ ๊ด์ฌํ์ง ์๊ณ ์ฝ๊ฐ์ ๋จ์๋ฅผ ์ ๊ณต ํ ์๋ ์์ต๋๋ค.
--> LAPACK TESTING SUMMARY <--
SUMMARY nb test run numerical error other error
================ =========== ================= ================
REAL 409288 0 (0.000%) 0 (0.000%)
DOUBLE PRECISION 410100 0 (0.000%) 0 (0.000%)
COMPLEX 420495 0 (0.000%) 0 (0.000%)
COMPLEX16 13940 0 (0.000%) 0 (0.000%)
--> ALL PRECISIONS 1253823 0 (0.000%) 0 (0.000%)
๊ฐ์ ์ค์ด ๋ง์ด ๋ณด์ด์ง๋ง
--> Testing DOUBLE PRECISION Nonsymmetric Eigenvalue Problem [ xeigtstd < nep.in > dnep.out ]
---- TESTING ./xeigtstd... FAILED(./xeigtstd < nep.in > dnep.out did not work) !
๊ทธ๋์ ์ด๊ฒ๋ค์ด ์ ๋ขฐํ ์ ์๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
๋๋ถ๋ถ์ ํ
์คํธ๊ฐ ์ธ๊ทธ ํดํธ ์ธ ๊ฒ ๊ฐ์ง๋ง, ์ด์๋จ์ ํ
์คํธ๋ ์๋ฒฝํฉ๋๋ค ... ์ด๊ฒ์ ์ ๊ฐ ์์ํ๋ ๊ฒ๋ณด๋ค ์กฐ๊ธ ๋ ๊ทน๋จ์ ์
๋๋ค.
(COMPLEX ๋ฐ COMPLEX16์ ์คํ ํฌ๊ธฐ ์ธก๋ฉด์์ ์ฝ๊ฐ ๊น๋ค๋กญ๊ธฐ ๋๋ฌธ์ ๊ธฐ๋ณธ OS ์ค์ ์ผ๋ก ์คํจ ํ ๊ฐ๋ฅ์ฑ์ด ํจ์ฌ ๋ ๋์ง๋ง REAL ๋ฐ DOUBLE์ ์ผ๋ฐ์ ์ผ๋ก ์ฝ 1200000 ๊ฐ์ ํ
์คํธ๊ฐ ์คํ๋์์์ ๋ณด์ฌ์ค๋๋ค. MS๊ฐ ๊ธฐ๋ณธ ์คํ์์ ๋ฌด์ธ๊ฐ๋ฅผ ๋ณ๊ฒฝํ๋์ง ๊ถ๊ธํฉ๋๋ค. ์ ํ ๋๋ ๋ ์ด์์)
์ฝ๊ฐ์ ๋ฐฐ๊ฒฝ. ๋ชจ๋ ๊ฒ์ gcc.exe / gfortran.exe๋ก ๋น๋๋ฉ๋๋ค. ์ด๋ค์ .a ํ์ผ์ ์์ฑํ๋ ๋ฐ ์ฌ์ฉ๋๋ฉฐ ๊ทธ ํ DLL๋ก ํจํค์ง๋ฉ๋๋ค. ๊ตฌ์ฒด์ ์ผ๋ก ํน๋ณํ:
$ gcc -v
Using built-in specs.
COLLECT_GCC=C:\git\numpy-openblas-windows\openblas-libs\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/git/numpy-openblas-windows/openblas-libs/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/7.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-7.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/include -I/c/mingw710/prerequisites/x86_64-zlib-static/include -I/c/mingw710/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/include -I/c/mingw710/prerequisites/x86_64-zlib-static/include -I/c/mingw710/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/include -I/c/mingw710/prerequisites/x86_64-zlib-static/include -I/c/mingw710/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/lib -L/c/mingw710/prerequisites/x86_64-zlib-static/lib -L/c/mingw710/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 7.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
$ gfortran -v
Using built-in specs.
COLLECT_GCC=C:\git\numpy-openblas-windows\openblas-libs\mingw64\bin\gfortran.exe
COLLECT_LTO_WRAPPER=C:/git/numpy-openblas-windows/openblas-libs/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/7.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-7.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/include -I/c/mingw710/prerequisites/x86_64-zlib-static/include -I/c/mingw710/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/include -I/c/mingw710/prerequisites/x86_64-zlib-static/include -I/c/mingw710/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/include -I/c/mingw710/prerequisites/x86_64-zlib-static/include -I/c/mingw710/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/lib -L/c/mingw710/prerequisites/x86_64-zlib-static/lib -L/c/mingw710/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 7.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
NumPy์ OpenBLAS ๊ฐ์ ํธ๋ ์คํ์ ๋ฌธ์ ๊ฐ ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ์ฒซ ๋ฒ์งธ ํธ์ถ์ด ์ค๋ฅ ์ธ ๊ฒฝ์ฐ์ด ๋์์ด ์ด๋ป๊ฒ ๋ฐ์ํ ์ ์๋์ง ์์ํ ์ ์์ง๋ง ๋ ๋ฒ์งธ ๋ฐ ํ์ ํธ์ถ์ ๋ชจ๋ ๊ด์ฐฎ์ต๋๋ค. ๊ทธ๋๋ ํด๊ฒฐํ๋ ๋ฐฉ๋ฒ (๋๋ TBH๊ฐ ๊น์ ๋ฌธ์ ๋ฅผ ์ ํํ๊ฒ ์ง๋จ) ...?
MS ํ๋ซํผ์ ํ์งํ๊ณ ํ๋ณตํ๊ฒ ์ด์ ๊ฐ์ธ์? ์คํจํ๋ฉด Lapack ํ ์คํธ๋ Fortran (= OpenBLAS์ LAPACK ๋ถ๋ถ)๊ณผ C ๋๋ Fortran๊ณผ "๋ค๋ฅธ ๊ฒ"์ฌ์ด์ ํธ๋ ์คํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
icc๋ฅผ ์ฌ์ฉํ์ฌ OpenBLAS๋ก Numpy๋ฅผ ๋น๋ ํ ์ ์๋์ง ๊ถ๊ธํฉ๋๋ค.
๋ฌธ์ ๊ฐ ์ง์๋๋์ง ํ์ธํ์ญ์์ค. ๊ทธ๋๋ ํฐ ์ง๋ฌธ์
๋๋ค.
2020 ๋ 8 ์ 12 ์ผ ์์์ผ 19:04 Martin Kroeker [email protected] ์ ๋ค์๊ณผ ๊ฐ์ด ์ผ์ต๋๋ค.
MS ํ๋ซํผ์ ํ์งํ๊ณ ํ๋ณตํ๊ฒ ์ด์ ๊ฐ์ธ์? ์คํจํ๋ฉด
lapack์ Fortran (= LAPACK์ ์ผ๋ถ
OpenBLAS) ๋ฐ C ๋๋ Fortran ๋ฐ "๊ธฐํ".โ
๋น์ ์ด ์ธ๊ธ ๋์๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ ๋ฐ๊ณ ์์ต๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ณ GitHub์์ ํ์ธํ์ธ์.
https://github.com/numpy/numpy/issues/16744#issuecomment-673026759 ๋๋
๊ตฌ๋ ์ทจ์
https://github.com/notifications/unsubscribe-auth/ABKTSRLSHZ2XWF4OE7J3QO3SALKSJANCNFSM4OP5IXNQ
.
์ธํ ์ปดํ์ผ๋ฌ๋ก OpenBLAS๋ฅผ ๊ตฌ์ถํ๋ ๊ฒ์ผ๋ก ์ถฉ๋ถํ ๊ฒ์ ๋๋ค (์ต์ํ ์ต๊ทผ์ ๋์จ VS์์ ๋ฌธ์ ๊ฐ๋๋ ๊ฒ ๊ฐ์ง๋ง ํ์ฌ ifc / ifort์ ๋ํ ์ ํจํ ๋ผ์ด์ผ์ค๊ฐ ์์ต๋๋ค.
2004 ๋ ์์ด ๋ฌธ์ ๊ฐ ํด๊ฒฐ ๋ ๋๊น์ง Windows ์ฌ์ฉ์๋ Conda / MKL์ ์ฌ์ฉํด์ผํฉ๋๋ค.
@bashtage ์ ์
์ ๊ฒฝ์ฐ์๋ Conda ๋ฒ์ ์ numpy๋ฅผ ์ ์ฉํ ํ pandasql์ ์ฌ์ฉํ์ฌ sqlite๋ฅผ ์ฌ์ฉํ ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.
ํ์ง๋ง์ด ๋ฒ์ ์ numpy + mkl์ ์ฌ์ฉํ ๋ ์๋ฌด๋ฐ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
@bashtage ๋ น ๋งํฌ ๋ฌธ์ ์ ๋ํ ์์ ์ฌํญ์ด์๋ ์๋ก์ด MSVC ํ๋ฆฌ ๋ฆด๋ฆฌ์ฆ๊ฐ์๋ ๊ฒ ๊ฐ์ต๋๋ค. ์๋ํด ๋ณผ ๊ฐ์น๊ฐ ์์ต๋๊น?
์ฐธ๊ณ : ๊ด๋ จ SciPy ๋ฌธ์ : https://github.com/scipy/scipy/issues/12747
Windows ๋น๋ 17763.1397 (8 ์ 11 ์ผ)์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ค๋๋ณด๊ณ ๊ฐ ์์ต๋๋ค. # 17082๋ฅผ ์ฐธ์กฐํ์ญ์์ค.
Windows ๋น๋ 17763.1397 (8 ์ 11 ์ผ)์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ค๋๋ณด๊ณ ๊ฐ ์์ต๋๋ค. # 17082๋ฅผ ์ฐธ์กฐํ์ญ์์ค.
https://support.microsoft.com/en-us/help/4565349/windows-10-update-kb4565349
๋น๋ 17763.1397์ Windows 10, ๋ฒ์ 1809 ์ ์ฉ์
๋๋ค (์ ์ฉ ๋์ : Windows 10, ๋ฒ์ 1809, ๋ชจ๋ ๋ฒ์ Windows Server ๋ฒ์ 1809Windows Server 2019, ๋ชจ๋ ๋ฒ์ ).
์ด ๊ฒฝ์ฐ Windows 10 ๋ฒ์ 1809์๋ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
์ด๊ฒ์ Windows 10, ๋ฒ์ 2004์ ์ต๊ทผ ์
๋ฐ์ดํธ ๋ฒ์ ์
๋๋ค.
https://support.microsoft.com/en-us/help/4566782
2020 ๋
8 ์ 11 ์ผ-KB4566782 (OS ๋น๋ 19041.450).
Windows 10, ๋ฒ์ 2004์์ ์ฌ์ ํ ๋์ผํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
19042.487์์ ๋์ผํ ์คํจ (20H2 ์ง์ ) :
-- Docs: https://docs.pytest.org/en/stable/warnings.html
=============================================== short test summary info ===============================================
FAILED lib/tests/test_regression.py::TestRegression::test_polyfit_build - numpy.linalg.LinAlgError: SVD did not conve...
FAILED linalg/tests/test_regression.py::TestRegression::test_eig_build - numpy.linalg.LinAlgError: Eigenvalues did no...
FAILED ma/tests/test_extras.py::TestPolynomial::test_polyfit - numpy.linalg.LinAlgError: SVD did not converge in Line...
3 failed, 11275 passed, 559 skipped, 20 xfailed, 1 xpassed, 1 warning in 398.16s (0:06:38)
๋๋ OpenBLAS์ lapack-test์์ (๋ถ๋ถ์ ์ธ) ์คํจ๋ฅผ ์ฌํ ํ ์ ์์ต๋๋ค-๋น์ ์์ ์ผ๋ก ๋์ ์คํ ํฌ๊ธฐ ์๊ตฌ ์ฌํญ์ด์๋ ๊ฒ์ผ๋ก ์๋ ค์ง EIG (๊ณ ์ ๊ฐ) ํ
์คํธ์๋ง ์ํฅ์ ๋ฏธ์นฉ๋๋ค. SIGSEGV๋ main () ์ด์ ์๋ ์
๋ ฅ ๋ __chkstk_ms_์์ ๋ฐ์ํฉ๋๋ค. peflags ์ ํธ๋ฆฌํฐ (์ : peflags -x4194304 -X4194304 EIG/xeigtsts.exe
)๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ ์คํ ํ์ผ์ ๊ธฐ๋ณธ "์คํ ์์ฝ ํฌ๊ธฐ"๋ฐ "์คํ ์ปค๋ฐ ํฌ๊ธฐ"๊ฐ์ ๋ ๋ฐฐ๋ก ์ค์ ํ๋ฉด ํ๋ก๊ทธ๋จ์ด ์ ์์ ์ผ๋ก ์๋ํ์ฌ C / Fortran ์ํธ ์์ฉ ๋ฐ ์ธ์ ์ ๋ฌ์ด ๋ค์๊ณผ ๊ฐ์์ ์์ฌํฉ๋๋ค. ๋ฌธ์ ์์ต๋๋ค. ๋๋ ์์ง ์ด๊ฒ์ numpy ์ผ์ด์ค์ ์ ์ฉํ๋ ค๊ณ ์๋ํ์ง ์์์ง๋ง (๋๊ตฌ์ peflag ์ค์ ์ ์กฐ์ ํ ์ง ํ์ ํ์ง ๋ชปํจ-python.exe?) 19041.450 ์ผ๋ช
gcc 9.1.0์ msys2 mingw64 ๋ฒ์ ์ผ๋ก ๋น๋ํ์ ๋ OpenBLAS ์์ฒด๊ฐ ์ ์์ ์ผ๋ก ์๋ํ๋ ๊ฒ์ฒ๋ผ ๋ณด์
๋๋ค. 2004 ๋
@ martin-frbg ์งํ ์ํฉ์ฒ๋ผ ๋ณด์ ๋๋ค.
Windows / MSYS2์์ numpy๋ฅผ ๋น๋ํ๊ธฐ ์ํด ๋ชจ๋ ์ข ์์ฑ์ ์ค์นํ๋ ค๊ณ ์๋ํ๋ ํ ๋ผ ๊ตฌ๋ฉ์ ๋น ์ ธ ๋ ์ด์ ์งํํ์ง ์์์ต๋๋ค.
@ martin-frbg, Msys2 ๊ธฐ๋ฐ numpy ํจํค์ง๋ pacman๊ณผ ํจ๊ป ์ค์นํ ์ ์์ต๋๋ค. Msys2 ๋น๋ ์คํฌ๋ฆฝํธ ๋ฐ ํจ์น๋ https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-python-numpy ๋ฐ https://github.com/msys2/MINGW-packages/tree์์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
์ต๊ทผ ๋ถ๋ฅ ํ์์์ ์ด๊ฒ์ ์๋์ ์ผ๋ก ๋์ ์ฐ์ ์์๋ก ๋ํ ๋ฌ ์ผ๋ฉฐ
@bashtage editbin /STACK:3145728 python.exe
์คํ์ ๋ ํฌ๊ฒ ๋ง๋ค ์ ์์ต๋๊น?
์ฐ๋ฆฌ๊ฐ ๋น๋ํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋์ OpenBLAS์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฆด๋ฆฌ์ค๋ก NumPy๋ฅผ ๋น๋ ํ ์์๋ ๋ฐฉ๋ฒ์ด ์์ต๋๊น? ์๋ง๋ ์ฐ๋ฆฌ์ ๋น๋๊ฐ ์ฝ๊ฐ ๋ฒ์ด๋ฌ์ต๋๋ค.
๋น๋์ libopenblas.dll์ ํ์ฌ develop
๋ธ๋์น ๋๋ 0.3.8 ๋๋ 0.3.9์ ๊ฐ์ ์ด์ ๋ฆด๋ฆฌ์ค์์ ๋ง๋ ๊ฒ์ผ๋ก ๋์ฒดํ์ฌ ํจ๊ณผ๊ฐ ์๋์ง ํ์ธํ ์ ์์ต๋๋ค. (์ง๊ธ ๋น์ฅ ์ผ๋์๋๊ณ ์๋ ํน์ ์ปค๋ฐ์ ๊ฐ์ง๊ณ ์๋ค๋ ๊ฒ์ ์๋๋๋ค.) ๋ถํํ๋ msys2 ํจํค์ง์์๋ ์ฌ์ ํ ์ค์น ์ค๋ฅ๊ฐ ๋ฐ์ํ๊ณ ์์ผ๋ฉฐ ํ์ฌ self.ld_version์ด ๋ฒ์ ๊ฒ์ฌ์์ ์๋ฌด๊ฒ๋ ๋ฐํํ์ง ์๊ธฐ ๋๋ฌธ์ ํ
์คํธ๋ฅผ ์คํํ ์ ์์ต๋๋ค.
๊ฐ์ฌ. 2004 ๋ ์ ๋ง๋ค๊ธฐ ์ํด ์ฐฝ๋ฌธ์ ์ ๋ฐ์ดํธํ๋ ค๊ณ ํฉ๋๋ค. ์ฃผ๋ง ์ ์ ๋๋ด๋์ง ๋ด ์๋ค.
๋ํ https://github.com/numpy/numpy/issues/16744#issuecomment -655430682์ bashtage์ "์์ ์ฌํ ์์ "๋ ๋ด msys2 ์ค์ ์์ ์ค๋ฅ๋ฅผ ๋ฐ์์ํค์ง ์์ต๋๋ค. (๋ด๊ฐ ๋งํ ์์๋ ํ, mingw64 / usr / lib์ libopenblas๋ Haswell์ ์ํด ๋น๋ ๋ ๋จ์ผ ์ค๋ ๋ 0.3.10์ ๋๋ค)
@ martin-frbg MSVC๋ฅผ ์ฌ์ฉํ์ฌ OpenBLAS๋ฅผ ๊ตฌ์ถ ํ ์ ์์ต๋๊น?
์ผ๋ฐ MSVC? ๊ฐ๋ฅํ์ง๋ง MSVC๊ฐ ์ด์ ๋ธ๋ฆฌ ์ปค๋์ ์ง์ํ์ง ์๊ธฐ ๋๋ฌธ์ ์ ๋๋ก ์ต์ ํ๋์ง ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ ๊ณตํฉ๋๋ค. TARGET = GENERIC ์ฉ์ผ๋ก OpenBLAS๋ฅผ ๋น๋ ํ ๊ฒ๊ณผ ๊ฑฐ์ ๊ฐ์ต๋๋ค.
๋ํ # 16744 (์ฃผ์) ์ bashtage์ "์์ ์ฌํ ์์ "๋ ๋ด msys2 ์ค์ ์์ ์ค๋ฅ๋ฅผ ๋ฐ์์ํค์ง ์์ต๋๋ค. (๋ด๊ฐ ๋งํ ์์๋ ํ, mingw64 / usr / lib์ libopenblas๋ Haswell์ ์ํด ๋น๋ ๋ ๋จ์ผ ์ค๋ ๋ 0.3.10์ ๋๋ค)
๋๋ ๊ทธ๊ฒ์ด NumPy์ OpenBLAS ๊ฐ์ ์ธํฐํ์ด์ค์ ๊ด๋ จ์ด ์๋ค๊ณ ํ์ ํฉ๋๋ค. NumPy์ 32 ๋นํธ ๋น๋์๋์ด ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ์ด๊ฒ์ด ์ค๋ ๋ ๋๊ธฐํ ๋ฌธ์ ์ผ ๊ฐ๋ฅ์ฑ์ด ๋๋ค๋ Microsoft ์ง์์ ์์ด๋์ด๊ฐ ๊ฐ์ฅ ๊ทธ๋ด๋ฏํ ๊ฒ ๊ฐ์ต๋๋ค. ์ฒซ ๋ฒ์งธ ํธ์ถ์ ์๋ชป๋ ๊ฐ์ด ์กด์ฌํ๊ณ ํ์ ํธ์ถ์์ ์์ ๋๋ ๋ฐฉ์์ ์ค๋ช ํ ์ ์์ต๋๋ค.
Windows / MSYS2์์ numpy๋ฅผ ๋น๋ํ๊ธฐ ์ํด ๋ชจ๋ ์ข ์์ฑ์ ์ค์นํ๋ ค๊ณ ์๋ํ๋ ํ ๋ผ ๊ตฌ๋ฉ์ ๋น ์ ธ ๋ ์ด์ ์งํํ์ง ์์์ต๋๋ค.
๊ณ ํต์ ๋๋ค. ํด๋ดค์ง๋ง ์คํ์ ์๋ํํ๋ ๋ฐ ์๊ฐ์ด ์ค๋ ๊ฑธ๋ ธ์ต๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก https://github.com/MacPython/openblas-libs ์์ ๋จ๊ณ๋ฅผ ๋ณต์ฌํ์ฌ .a ํ์ผ์ ๊ฐ์ ธ์จ ๋ค์ https://github.com/numpy/numpy/blob/master/ ์์ ๋จ๊ณ๋ฅผ ๋ณต์ฌํด์ผํฉ๋๋ค.
DLL ๋น๋๋ฅผ ์ป๋ ๊ฐ์ฅ ์ฌ์ด ๋ฐฉ๋ฒ์ appveyor ๊ณ์ ์ ์ฐ ๋ค์ https://github.com/MacPython/openblas-libs ๋ฅผ ๋ณต์ ํ๋ ๊ฒ
https://github.com/MacPython/openblas-libs๋ฅผ ๋ณด๋ฉด OpenBLAS๊ฐ INTERFACE64=1
๋ก ๋น๋ ๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ด๊ฒ์ Msys2 ๋น๋ OpenBLAS ๋ฐ numpy์ ๊ฒฝ์ฐ๊ฐ ์๋๋๋ค .
@carlkl ์ด ๋ฌธ์ ๋ NumPy ๋๋ OpenBLAS์ Msys2 ๋น๋์ ๊ดํ ๊ฒ์ด ์๋๋๋ค. ์ด๋ Msys2์์ ์ ๊ณต ํ gfortran์ ์ฌ์ฉํ์ฌ ํฌํธ๋ ์์ค๋ฅผ ์ปดํ์ผ ํ ๋ค์ MS์ lib.exe๋ฅผ ์ฌ์ฉํ์ฌ ์ปดํ์ผ ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ Win32 DLL์ ๋น๋ํ๋ Win32 / AMD64 ๋น๋์ ๊ดํ ๊ฒ์ ๋๋ค.
์ด๋ณด๊ณ ๋์๊ธฐ ๋๋ฌธ์ @bashtage ๋๋์ด ์ธ๊ธ https://github.com/numpy/numpy/issues/16744#issuecomment ๋ segfault๊ฐ msys2 ๋ด์์ ์ฌ์๋์ง ์, -689785607. ๊ทธ๋ฆฌ๊ณ ์ธ๊ธ ๋ msys2 ํ๊ฒฝ์๋ msys2 ์ ๊ณต openblas ๋ฐ numpy ๋ฐ์ด๋๋ฆฌ ํจํค์ง๊ฐ ํฌํจ๋์ด ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
Windows 64bit numpy๊ฐ MSVC์ ์ ์ฌํ ํ๋๊ทธ๋ก ์ปดํ์ผ๋์๋์ง ์ฌ๋ถ๋ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
BTW : scipy ์ ์ฅ์์์ -fdefault-integer-8
ํ๋๊ทธ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.
-fdefault-integer-8
๋ก ์ปดํ์ผ ๋ ์ฝ๋๊ฐ์ด ํ๋๊ทธ์์ด ์ปดํ์ผ ๋ ์ฝ๋์ ABI ํธํ๋๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
๋ ๋ค๋ฅธ ์ธก๋ฉด์ด ๋ ์ฌ๋์ต๋๋ค. -fdefault-integer-8
๋ -mcmodel=large
์ ๊ฒฐํฉ๋์ด์ผํฉ๋๋ค.
ํธ์ง : ๊ธฐ์ตํ์ญ์์ค : Windows64์๋ ILP64๊ฐ ์๋ LLP64 ๋ฉ๋ชจ๋ฆฌ ๋ชจ๋ธ์ด ์์ต๋๋ค.
LLP64๋ long : 32bit, ํฌ์ธํฐ : 64bit๋ฅผ ์๋ฏธํฉ๋๋ค.
๊ทธ๋ ๋ค๋ฉด Win10-2004 ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ numpy ๋น๋๋ ์ด๋ค ํฌ๊ธฐ์ ์ ์๋ฅผ ์ฌ์ฉํฉ๋๊น? OpenBLAS๊ฐ ๊ตฌ์ถ ํ ๊ฒ๊ณผ ๋ ์ ์ผ์นํ์ง๋ง IIRC์ด ์ฃผ์ ๋ ์ด๋ฏธ์ด ์ค๋ ๋์ ์ด๊ธฐ์ ๋ํ๋ฌ์ต๋๋ค (๋ถ์ผ์น๋ก ์ธํด Windows ํจ์น ์์ค์ ๊ด๊ณ์์ด ๋ ๋๋ ทํ ์์์ด ๋ฐ์ํ ์ ์์ต๋๋ค).
์ต์ํ Openblas๋ https://github.com/MacPython/openblas-libs๋ฅผ ์ฌ์ฉํ์ฌ ์ธ ๊ฐ์ง ๋ณํ์ผ๋ก ๋น๋ ํ ์ ์์ต๋๋ค (appveyor.yml ์ฐธ์กฐ).
๊ทธ๋ฌ๋ Windows์์ numpy 64bit ๋น๋์ ์ฌ์ฉ๋๋ ๊ฒ์ด ๋ฌด์์ธ์ง ๋ชจ๋ฅธ๋ค๋ฉด.
_ ๋ถ์ผ์น๋ก ์ธํด Windows ํจ์น ์์ค์ ๊ด๊ณ์์ด ๋ ๋๋ ทํ ์์์ด ๋ฐ์ํ ์ ์์ต๋๋ค _
-fdefault-integer-8
๋ Lapack์ ํฌํธ๋ ๋ถ๋ถ์๋ง ์ ์ฉ๋ฉ๋๋ค. ๊ธฐ๋ณธ ๋ฉ๋ชจ๋ฆฌ ๋ชจ๋ธ (LLP64)์ ๋ณ๊ฒฝํ์ง ์์ผ๋ฏ๋ก Fortran Lapack ๋ถํ ์ธ๋ถ์์ ๋ฌธ์ ๋ฅผ ์์ํด์ผํ๋์ง ํ์คํ์ง ์์ต๋๋ค.
ํ ,
https://github.com/numpy/numpy/blob/60a21a35210725520077f13200498e2bf3198029/azure-pipelines.yml ๋ผ๊ณ
- job: Windows
pool:
vmImage: 'VS2017-Win2016'
...
Python38-64bit-full:
PYTHON_VERSION: '3.8'
PYTHON_ARCH: 'x64'
TEST_MODE: full
BITS: 64
NPY_USE_BLAS_ILP64: '1'
OPENBLAS_SUFFIX: '64_'
๋ค๋ฅธ ๋ชจ๋ ๋ฒ์ ( Python36-64bit-full
, Python37-64bit-full
)์ NPY_USE_BLAS_ILP64์์ด ๋น๋๋ฉ๋๋ค.
pypi.org์ Numpy ๋ฐ์ด๋๋ฆฌ๋ ๋ชจ๋ 32 ๋นํธ ์ ์ openbla๋ก ๋น๋๋ฉ๋๋ค. https://github.com/MacPython/numpy-wheels/blob/v1.19.x/azure/windows.yml
๋น๋ ํ๋ก์ธ์ค gfortran ๋ MSVC ์ธ๋ถ ์ ๋ณด๋ ์ฌ๊ธฐ๋ฅผ ์ฐธ์กฐ openblas.a
ํ์ผ์ ์ฌ์ฉํ๊ณ gfortran์ ์ฌ์ฉํ์ฌ DLL์ ์์ฑํฉ๋๋ค. https://github.com/numpy/numpy/blob/74712a53df240f1661fbced15ae984888fd9afa6/numpy/distutils/fcompiler/gnu.py#L442 MSVC ๋๊ตฌ๋ .def ํ์ผ์์ .lib ํ์ผ์ ์์ฑํ๋ ๋ฐ ์ฌ์ฉ๋๋ฉฐ MSVC๋ก ์ปดํ์ผ ๋ Numpy C ์ฝ๋ .lib ํ์ผ์ ์ฌ์ฉํ์ฌ gfortran์์ ์์ฑ ํ DLL์ ์ฐ๊ฒฐ๋ฉ๋๋ค.
์๋ชป ๋ ์์๋ ํ ๊ฐ์ง ์ด๋ก ์ ๊ฐ๋ฅ์ฑ์ ์ ์ openblas.a ์ํฐํฉํธ๋ฅผ ์์ฑ ํ mingw์ numpy๊ฐ ๋น๋ ๋ ๋ ์ฌ์ฉ ๋ mingw ๋ฒ์ ๊ฐ์ ์ผ์ข ์ mingw ๋ฒ์ ๋ถ์ผ์น๊ฐ์๋ ๊ฒฝ์ฐ์ ๋๋ค. ๊ทธ๋ฌ๋ ์ด๊ฒ์ด ๋ฌธ์ ๋ฅผ ์ผ์ผํฌ ์ ์๋์ง ํ์คํ์ง ์์ต๋๋ค.
choco install -y mingw --forcex86 --force --version=5.3.0
์ ์ฌ์ฉ๋๋ windows.yml
๋ณด์ธ๋ค๋ ์ค๋๋ํฉ๋๋ค. 7.3.0
๋๋ 8.1.0
์ฌ์ฉํ์ง ์๋ ์ด์ ๋ ๋ฌด์์
๋๊น? 2 ~ 3 ๋
์ ์ gcc-5.x์์ ๊ฒช์๋ ๋ฌธ์ ๋ฅผ ๊ธฐ์ตํ ์ ์์ต๋๋ค.
choco install -y mingw --forcex86 --force --version = 5.3.0 windows.yml์์ ์ฌ์ฉ ๋ ๊ฒ์ด ์ค๋๋ ๊ฒ ๊ฐ์ต๋๋ค.
์ด๋ 32 ๋นํธ Windows ๋น๋ ์ ์ฉ์ด๋ฏ๋ก์ด ๋ฌธ์ ์ ๊ด๋ จ์ด ์์ ์ ์์ต๋๋ค.
๋ค๋ฅธ ๋ชจ๋ ๋ฒ์ (
Python36-64bit-full
,Python37-64bit-full
)์ NPY_USE_BLAS_ILP64์์ด ๋น๋๋ฉ๋๋ค.
Python 3.6 ๋ฐ 3.8์์ ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
ํ ๊ฐ์ง ์์ด๋์ด๊ฐ ๋จ์์ต๋๋ค (๋๋ ์ด๋ ์์์ ํ๊ณ ์์ต๋๋ค) :
OpenBLAS๋ ์ด์ -fno-optimize-sibling-calls
์ปดํ์ผ๋ฉ๋๋ค. https://github.com/xianyi/OpenBLAS/issues/2154 , https://github.com/xianyi/OpenBLAS/pull/2157 ๋ฐ https : // gcc ์ฐธ์กฐ .gnu.org / bugzilla / show_bug.cgi? id = 90329.
ํธ์ง : ์ฐธ์กฐ : https://gcc.gnu.org/legacy-ml/fortran/2019-05/msg00181.html
Numpy๋ distutils์ gfortran ๋ถ๋ถ์์ด ํ๋๊ทธ๋ฅผ ์ ์ฉํ์ง ์์์ต๋๋ค. numpy๊ฐ MSVC๋ก ์ปดํ์ผ๋๋ค๋ ๊ฒ์ ์๊ณ ์์ต๋๋ค. ๋ฐ๋ผ์ numpy๋ณด๋ค๋ scipy์ ๋ฌธ์ ๊ฐ์์ ๊ฒ์ผ๋ก ์์ํ๋ฏ๋ก ์ด๊ฒ์ ๋ค์ ์๋ชป๋ ์ฌํ ์ผ ์ ์์ต๋๋ค.
pypi.org์ Numpy ๋ฐ์ด๋๋ฆฌ๋ ๋ชจ๋ 32 ๋นํธ ์ ์ openbla๋ก ๋น๋๋ฉ๋๋ค. https://github.com/MacPython/numpy-wheels/blob/v1.19.x/azure/windows.yml
ํ ์คํธ์ ์ฌ์ฉ ๋ ๋น๋ ๊ตฌ์ฑ์ด ๋ฆด๋ฆฌ์ค์ ์ฌ์ฉ ๋ ๊ตฌ์ฑ๊ณผ ๋ค๋ฅธ ์ด์ ๋ ๋ฌด์์ ๋๊น? ์ด๊ฒ์ ์ํ์ฒ๋ผ ๋ค๋ฆฝ๋๋ค.
Azure ๋น๋์ ์ํฐํฉํธ๋ฅผ ์ถ๊ฐ ํ ์ ์์ต๋๊น? ์ด๊ฒ์ ํ ์คํธ๋ฅผ ์ํด ๋ฐํด๋ฅผ ์ป๋ ๊ฒ์ ํจ์ฌ ๋ ๊ฐ๋จํ๊ฒ ๋ง๋ค ๊ฒ์ ๋๋ค. ์ฌ๊ธฐ์ ๋ด ์ ์ผํ ๊ด์ฌ์ฌ๋ ๋ฌด๋ฃ ์ํฐํฉํธ ์ ํ์ด IIRC, 1GB๋ก ๋งค์ฐ ์์ผ๋ฉฐ์ด๋ฅผ ๋๋ ธ์ ๋ ์ด๋ค ์ผ์ด ๋ฐ์ํ๋์ง ๋ชจ๋ฅด๊ฒ ๋ค๋ ๊ฒ์ ๋๋ค (FIFO๋ ์ข์ง๋ง ์ค๋ฅ๋ฅผ ํฌํจํ ๋ค๋ฅธ ์์ ์ ์ํ ํ ์ ์์).
ํ ์คํธ์ ์ฌ์ฉ ๋ ๋น๋ ๊ตฌ์ฑ์ด ๋ฆด๋ฆฌ์ค์ ์ฌ์ฉ ๋ ๊ตฌ์ฑ๊ณผ ๋ค๋ฅธ ์ด์ ๋ ๋ฌด์์ ๋๊น?
NPY_USE_BLAS_ILP64
์๋ Windows์์ ์ง์๋๋ ๋ชจ๋ Python ๋ฒ์ ์ ํ
์คํธํ๊ณ NPY_USE_BLAS_ILP64
๋ก Python 3.8๋ ํ
์คํธํฉ๋๋ค ( https://github.com/numpy/numpy/blob/v1.19.2/azure ์ฐธ์กฐ). -pipelines.yml # L195. ๋ฐ๋ผ์ ์ฃผ๊ฐ ๋น๋๋ 32 ๋นํธ ์ ์ openbla๋ฅผ ์ฌ์ฉํ๋ ๋ฐ ์ ํํฉ๋๋ค.
Azure ๋น๋์ ์ํฐํฉํธ๋ฅผ ์ถ๊ฐ ํ ์ ์์ต๋๊น?
์๋ง ์ด๊ฒ์ ์๋ํ๊ณ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ฉด ํ๊ณ์ ๋ํด ์์๋ด๋ ๊ฒ์ด ์ฌ์ธ ๊ฒ์ ๋๋ค. ๊ทธ๋ฌ๋ ์ฃผ๊ฐ ํ ์ ํ ์คํธ ๋น๋๋ฅผ ์ถฉ์คํ ์ฌํํ๊ธฐ์ํ ๊ฒ์ ๋๋ค. ๋ชจ๋ ๋ถ์ผ์น๋ ์ค๋ฅ๋ก ์ฒ๋ฆฌ๋๊ณ ์์ ๋์ด์ผํฉ๋๋ค.
์๋ง ์ด๊ฒ์ ์๋ํ๊ณ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ฉด ํ๊ณ์ ๋ํด ์์๋ด๋ ๊ฒ์ด ์ฌ์ธ ๊ฒ์ ๋๋ค. ๊ทธ๋ฌ๋ ์ฃผ๊ฐ ํ ์ ํ ์คํธ ๋น๋๋ฅผ ์ถฉ์คํ ์ฌํํ๊ธฐ์ํ ๊ฒ์ ๋๋ค. ๋ชจ๋ ๋ถ์ผ์น๋ ์ค๋ฅ๋ก ์ฒ๋ฆฌ๋๊ณ ์์ ๋์ด์ผํฉ๋๋ค.
๋ฉ์ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ ๋ํ PR์์ ์คํํ๊ณ 2004 ๋ ์ ํ ์คํธ ํ ์ํฐํฉํธ๋ฅผ ๊ฐ์ ธ ์ค๋ ๊ฒ์ด ๋ ์ฌ์ธ ๊ฒ์ด๋ผ๊ณ ์๊ฐํ์ต๋๋ค.
๋ง์ด๋๋ค.
๋ฆฌํฌ์งํ ๋ฆฌ bashtage / numpy์์ Azure ํ์ดํ ๋ผ์ธ์ ์ผค ์ ์์ต๋๋ค.
์ถ๊ฐ ์ ๋ณด : ์ฒซ ๋ฒ์งธ ํธ์ถ์ด ์คํจํ ์ด์ ๋ OpenBLAS ๋ด๋ถ์์ DNRM2
๊ฐ NAN์ ๋ฐํํ๊ธฐ ๋๋ฌธ์
๋๋ค. ์ ์๊ฒ ์ด๊ฒ์ ๋ฐ๋ณต ๊ฐ๋ฅํฉ๋๋ค.
a = np.arange(13 * 13, dtype=np.float64).reshape(13, 13)
a = a % 17
np.linalg.eig(a)
** On entry to DGEBAL parameter number 3 had an illegal value
์ธ์ํฉ๋๋ค. ์ด๋ " DNRM2
returned NAN"์ ๋งํ๋ ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์
๋๋ค. mod
์์
์ ๋งค์ฐ ์ค์ํฉ๋๋ค.์ด ์์
์ด ์์ผ๋ฉด eig
ํธ์ถํด๋์ด ์ค๋ฅ๊ฐ ์ธ์๋์ง ์์ต๋๋ค.
mod
ufunc์ OpenBLAS ํธ์ถ๊ฐ์ ์ด๋ป๊ฒ ์ํธ ์์ฉ์ด์์ ์ ์์ต๋๊น?
mod
์์ ์ ๋งค์ฐ ์ค์ํฉ๋๋ค.์ด ์์ ์ด ์์ผ๋ฉดeig
ํธ์ถํด๋์ด ์ค๋ฅ๊ฐ ์ธ์๋์ง ์์ต๋๋ค.
์ด ์ ํํ ๋์ผํ ์ด๋ ์ด๋ฅผ ์๋์ผ๋ก ๋ฐ๋ณต์ ์ผ๋ก ๊ตฌ์ฑํ๋ฉด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๊น?
์ด ์ฝ๋๋ ์คํจ๋ฅผ ํธ๋ฆฌ๊ฑฐํ์ง ์์ต๋๋ค.
a = np.array([x % 17 for x in range(13 * 13)], dtype=np.float64)
a.shape = (13, 13)
np.linalg.eig(a)
์์ mod
๊ฐ ๋ ์ง์คํฐ๋ฅผ ์ ์๋์ง ์์ ์ํ๋ก ๋จ๊ฒจ ๋ ์ ์์ต๋๊น? nrm2.S๋ฅผ ๋ค์ ํ์ธํ์ง ์์์ง๋ง ๋ช ๋
์ ์ด์
๋ธ๋ฆฌ XOR์์ ๋ ์ง์คํฐ๋ฅผ ์์ฒด์ ์ผ๋ก XORํ์ฌ์ด๋ฅผ ์ง์ฐ๋ ๋ฐ ๋ช ๋
์ ๋ฌธ์ ๊ฐ ์์๋๋ฐ, ์ด๋ NaN์์ ์คํจ ํ ๊ฒ์
๋๋ค.
๋ค์์ ๋ฐ๋ฅด๋ ์ฌ๋๋ค์ ๊ฒฝ์ฐ float64 %
๋ ๊ฐ ๊ฐ์ ๋ํด npy_divmod
๋ฅผ ํธ์ถํฉ๋๋ค.
... ์ฒซ ๋ฒ์งธ ์ค์์ npy_fmod()
ํธ์ถํ๋ฉฐ ์ด๋ fmod () ์
๋๋ค. ๋ด๊ฐ ์๋ํ ๋ช ๊ฐ์ง ๋ณ๊ฒฝ ์ฌํญ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. "์ค๋ฅ"๋ a % 17; np.linalg.eig(a)
๋ฅผ ํธ์ถํ๋ ์ฝ๋๋ฅผ ์คํํ ๋ OpenBLAS์์ "์๋ชป๋ ๊ฐ"๋ฉ์์ง๊ฐ ํ์๋จ์ ์๋ฏธํฉ๋๋ค.
์ฝ๋ | ๊ฒฐ๊ณผ
--- | ---
mod = npy_fmod@c@(a, b);
(์๋ ์ฝ๋) | ์ค๋ฅ
mod = 100; //npy_fmod@c@(a, b);
| ์ค๋ฅ ์์
mod = npy_fmod@c@(a, b); mod = 100.0;
| ์ค๋ฅ
๋ฐ๋ผ์ MSVC์ fmod
๊ฐ OpenBLAS๋ฅผ ํผ๋์ค๋ฝ๊ฒํ๋ ์ผ์ํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
ํฅ๋ฏธ๋กญ๊ณ ์ด์ํฉ๋๋ค.
fmod์ ์์งํ (ํ๋ซํผ์ด ์ ๊ณต๋์ง ์์) ๋ฒ์ ์ ์ฌ์ฉํ์ฌ ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์๋์ง ํ์ธํ ์ ์์ต๋๊น?
๋๋ HAVE_MODF
๋ฅผ 0
๊ฐ์ ํฉ๋๋ค.
fmod์ ์์งํ ๋ฒ์ ์ด ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
HAVE_MODF ๋งคํฌ๋ก๊ฐ ์์ง๋ง ์ด ๊ฒฝ๋ก ๋ ์ด๋๋ก ์ฐ๊ฒฐ๋ฉ๋๊น?
float์ long double์ด ๋๋ฝ๋๋ฉด ์ด์ค ๋ฒ์ ์ผ๋ก ๋์๊ฐ๋๋ค. numpy๋ฅผ ๋น๋ํ๋ ค๋ฉด ์ด์ค ๋ฒ์ ์ด ํ์์ ๋๋ค. undef๋ ์๋ง๋ ์ค๋ ์ ์ Windows์์ ๋ฌธ์ ์๋ ์ปดํ์ผ๋ฌ ์ธ๋ผ์ธ ํจ์ ์ธ ISTR์ ํผํ๋ ๊ฒ์ ๋๋ค.
๋๋ ๋ฌธ์ ๊ฐ ucrtbase.dll
์์ ๋น๋กฏ๋ fmod
๊ตฌํ์์ "์ฆ๋ช
"ํ๊ณ ์ถ์์ต๋๋ค. ๊ทธ๋์ ๋๋ ctypes๋ฅผ ์ฌ์ฉํ์ฌ dll์์ ํจ์๋ฅผ ๊ฐ์ ธ์ค๊ณ fmod
์ง์ ํธ์ถํ๋ ๋์ ์ฌ์ฉํ๋ ์ฝ๊ฐ์ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์์ฑํ์ต๋๋ค. ํ
์คํธ๋ ์ฌ์ ํ ์คํจํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ ucrtbase.dll
์ ์ด์ ๋ฒ์ ์ผ๋ก ์ ํํ์ต๋๋ค ( fmod
ํจ์์๋ง ํด๋น). ํ
์คํธ๋ฅผ ํต๊ณผํ์ต๋๋ค. Visual Studio ํฌ๋ผ ์์
diff --git a/numpy/core/src/npymath/npy_math.c b/numpy/core/src/npymath/npy_math.c
index 404cf67b2..675905f73 100644
--- a/numpy/core/src/npymath/npy_math.c
+++ b/numpy/core/src/npymath/npy_math.c
@@ -7,3 +7,27 @@
#define NPY_INLINE_MATH 0
#include "npy_math_internal.h"
+#include <Windows.h>
+
+typedef double(*dbldbldbl)(double, double);typedef double(*dbldbldbl)(double, double);
+
+dbldbldbl myfmod = NULL;
+
+typedef double(*dbldbldbl)(double, double);
+extern dbldbldbl myfmod;
+
+
+double __fmod(double x, double y)
+{
+ if (myfmod == NULL) {
+ HMODULE dll = LoadLibraryA("ucrtbase_old.dll");
+ //HMODULE dll = LoadLibraryA("c:\\windows\\system32\\ucrtbase.DLL");
+ myfmod = (dbldbldbl)GetProcAddress(dll, "fmod");
+ }
+ return myfmod(x, y);
+}
+
+long double __fmodl(long double x, long double y) { return fmodl(x, y); }
+float __fmodf(float x, float y) { return fmodf(x, y); }
+
+
diff --git a/numpy/core/src/npymath/npy_math_internal.h.src b/numpy/core/src/npymath/npy_math_internal.h.src
index 18b6d1434..9b0600a34 100644
--- a/numpy/core/src/npymath/npy_math_internal.h.src
+++ b/numpy/core/src/npymath/npy_math_internal.h.src
@@ -55,6 +55,11 @@
*/
#include "npy_math_private.h"
+double __fmod(double x, double y);
+long double __fmodl(long double x, long double y);
+float __fmodf(float x, float y);
+
+
/*
*****************************************************************************
** BASIC MATH FUNCTIONS **
@@ -473,8 +478,8 @@ NPY_INPLACE @type@ npy_@kind@@c@(@type@ x)
/**end repeat1**/
/**begin repeat1
- * #kind = atan2,hypot,pow,fmod,copysign#
- * #KIND = ATAN2,HYPOT,POW,FMOD,COPYSIGN#
+ * #kind = atan2,hypot,pow,copysign#
+ * #KIND = ATAN2,HYPOT,POW,COPYSIGN#
*/
#ifdef HAVE_@KIND@@C@
NPY_INPLACE @type@ npy_@kind@@c@(@type@ x, @type@ y)
@@ -484,6 +489,13 @@ NPY_INPLACE @type@ npy_@kind@@c@(@type@ x, @type@ y)
#endif
/**end repeat1**/
+#ifdef HAVE_FMOD@C@
+NPY_INPLACE @type@ npy_fmod@c@(@type@ x, @type@ y)
+{
+ return __fmod@c@(x, y);
+}
+#endif
+
#ifdef HAVE_MODF@C@
NPY_INPLACE @type@ npy_modf@c@(@type@ x, @type@ *iptr)
{
fmod ํธ์ถ ํ ์ฝ๋๋ฅผ ์ถ๊ฐํ์ฌ ST(0)
nan์ด ํฌํจ๋์ง ์๋๋กํ๋ฉด ์ด๋ป๊ฒ๋ฉ๋๊น? ์๋๋ฉด ์ข
ํฉ์ ์ผ๋ก nan์ผ๋ก ์ค์ ํ์๊ฒ ์ต๋๊น?
ํธ์ถ ๊ท์น์ด ์ด๋ฌํ ๋ ์ง์คํฐ์ ๋์ ๋ฐฉ์์ ์ ์ฝ์ ๊ฐํฉ๋๊น?
๋๋ ๋ฌธ์ ๊ฐ
ucrtbase.dll
์์ ๋น๋กฏ๋fmod
๊ตฌํ์์ "์ฆ๋ช "ํ๊ณ ์ถ์์ต๋๋ค. ๊ทธ๋์ ๋๋ ctypes๋ฅผ ์ฌ์ฉํ์ฌ dll์์ ํจ์๋ฅผ ๊ฐ์ ธ์ค๊ณfmod
์ง์ ํธ์ถํ๋ ๋์ ์ฌ์ฉํ๋ ์ฝ๊ฐ์ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์์ฑํ์ต๋๋ค. ํ ์คํธ๋ ์ฌ์ ํ ์คํจํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ucrtbase.dll
์ ์ด์ ๋ฒ์ ์ผ๋ก ์ ํํ์ต๋๋ค (fmod
ํจ์์๋ง ํด๋น). ํ ์คํธ๋ฅผ ํต๊ณผํ์ต๋๋ค. Visual Studio ํฌ๋ผ ์์
์ต์ํ ์ฌ๊ธฐ์ ๋ง์ ์ฌ๋๋ค์ด์์ ๊ฒ ๊ฐ์ azure ๊ณ์ ์ ๊ฐ์ง ์ฌ๋์ ๋๊ตฌ๋ ๊ทธ๊ฒ์ ์ฐฌ์ฑ ํ ์ ์์ต๋๋ค. ์ด ๋ฌธ์ ๊ฐ ์ฒ์์ ๋ํ ๋ฌ์ ๋ Azure ML์์ ์์ ํ๋ ์ฐ๋ฝ์ฒ ์ค ์ผ๋ถ์๊ฒ ์ฐ๋ฝํ์ฌ ์์ ์ ์ํ ํ ์ ์๋์ง ํ์ธํฉ๋๋ค.
์ต์ํ ์ฌ๊ธฐ์ ๋ง์ ์ฌ๋๋ค์ด์์ ๊ฒ ๊ฐ์ azure ๊ณ์ ์ ๊ฐ์ง ์ฌ๋์ ๋๊ตฌ๋ ๊ทธ๊ฒ์ ์ฐฌ์ฑ ํ ์ ์์ต๋๋ค.
ํ์ ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
fmod์ ์์งํ ๋ฒ์ ์ด ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
์๋์. IEEE-754 ์ฌ์์์ ํน์ ๋์์ ์ํํ๋ ๋ฐ ํ์ํ ๊น๋ค๋ก์ด ๊ธฐ๋ฅ์ ๋๋ค. ๋ํ ์ฌ์๊ณผ ๊ด๋ จ์ด์๋ ๋งค์ฐ ๋๋ฆฝ๋๋ค.
์ ๋
ธ๋ ฅ fmod
์ ์ํด ์ํ fprem
์ฌ์ง์ด VS2019์ ๋ณํ์์, x87 instuction - @mattip ๋ณผ์ ์์ (๋ง์ง๋ง ์ค) https://gist.github.com/mattip / d9e1f3f88ce77b9fde6a285d585c738e. ( fprem1
๋ remainder
๋ณํ btw์
๋๋ค.)
MMX ๋๋ SSE ๋ ์ง์คํฐ์ ํจ๊ป ์ฌ์ฉํ ๋๋์ฃผ์ํด์ผํฉ๋๋ค. https://stackoverflow.com/questions/48332763/where-does-the-xmm-instruction-divsd-store-the-remainder.
https://github.com/xianyi/OpenBLAS/issues/2709#issuecomment -702634696์ ์ค๋ช ๋๋๋ก ์ฌ์ฉํ ์์๋ ๋ช ๊ฐ์ง ๋์ฒด ๊ตฌํ์ด ์์ต๋๋ค. ๊ทธ๋ฌ๋์ด ๋ชจ๋ ๊ฒ์ ์ปดํ์ผ์ ์ํด gcc (mingw-w64)๊ฐ ํ์ํฉ๋๋ค. OpenLIBM์ MSVC AFAIK๋ก ์ปดํ์ผ๋์ง ์์ต๋๋ค. ์ธ๋ผ์ธ ์ด์ ๋ธ๋ฌ ์ฝ๋๋ MSVC์์ ํ์ฉ๋์ง ์์ต๋๋ค. ์์น์ ์ผ๋ก numpy ๋น๋ ์ค์ fmod ๋์ฐ๋ฏธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋น๋ (mingw-w64)ํ๊ณ ์ฌ์ฉํ ์ ์์ต๋๋ค (MSVC).
fmod ํธ์ถ ํ์ ์ฝ๋๋ฅผ ์ถ๊ฐํ์ฌ ST (0)์ nan์ด ํฌํจ๋์ง ์๋๋กํ๋ฉด ์ด๋ป๊ฒ๋ฉ๋๊น? ์๋๋ฉด ์ข ํฉ์ ์ผ๋ก nan์ผ๋ก ์ค์ ํ์๊ฒ ์ต๋๊น? ํธ์ถ ๊ท์น์ด ์ด๋ฌํ ๋ ์ง์คํฐ์ ๋์ ๋ฐฉ์์ ์ ์ฝ์ ๊ฐํฉ๋๊น?
Windows์์ OpenBLAS๋ฅผ ํธ์ถํ๊ธฐ ์ ์ ๋ ์ง์คํฐ๋ฅผ ์ง์ฐ๋ ์์ ์ด์
๋ธ๋ฆฌ๋ฅผ ์ถ๊ฐ ํ ์ ์์ต๋๋ค. ๋๋ ์ฝ๊ฐ์ ํ
์คํธ ์ค์ ์์ ์ด๊ฒ์ ์๋ํ์ง๋ง ๋ด masm ์ด์
๋ธ๋ฆฌ foo๊ฐ ์ฝํฉ๋๋ค. fldz
์ฌ๋ฌ ๋ฒ ํธ์ถํ๋ ํ๋ก ์์ ๋ฅผ ์์ฑํ๋ ค๊ณ ํ์ง๋ง ์ฌ์ฉํ ๋ ์์ธ๊ฐ ๋ฐ์ํฉ๋๋ค. ๋์?
lots_of_fldz.asm
:
.code
lots_of_fldz proc
fldz
fldz
fldz
fldz
fldz
fldz
lots_of_fldz endp
end
๋ค๋ฅธ ํ์ผ์์ :
#include <iostream>
#include <Windows.h>
extern "C" {
int lots_of_fldz(void);
}
int main()
{
typedef double(*dbldbldbl)(double, double);
//HMODULE dll = LoadLibraryA("D:\\CPython38\\ucrtbase_old.dll");
HMODULE dll = LoadLibraryA("c:\\windows\\system32\\ucrtbase.DLL");
if (dll == NULL) {
return -1;
}
dbldbldbl myfmod;
myfmod = (dbldbldbl)GetProcAddress(dll, "fmod");
double x = 0.0, y = 17.0;
double z = x + y;
z = myfmod(x, y);
lots_of_fldz();
/* CRASH */
std::cout << "Hello World!\n";
return 0;
}
VisualStudio ํ๋ก์ ํธ์ ๋ฃ๊ณ ์ด ๊ฐ์ด๋ ์ ๋ฐ๋ผ masm ์ปดํ์ผ์ ์ผญ๋๋ค.
@mattip , mingw-w64 (64 ๋นํธ)์ ํด๋น fmod
ํจ์์์๋ ๊ฒ๊ณผ ๋์ผํ text:
์ธ๊ทธ๋จผํธ๋ฅผ ๋ง๋๋ 64 ๋นํธ fmod ํจ์์ ๋ํ ์ด์
๋ธ๋ฌ ํ์ผ์ ๋ง๋ค์์ต๋๋ค. ์ด๊ฒ์ด ๋ฒ๊ทธ๊ฐ์๋ fmod ํจ์๋ฅผ ๋์ฒดํ๋ ๊ฒ์ผ๋ก ์๋ํ๋์ง ์ ์ ์์ง๋ง ์ ์ด๋ ํ๋๋ ์๋ ํด๋ด์ผํฉ๋๋ค. ๊ฒฐ๊ณผ obj ํ์ผ์ npymath.lib์ ์ถ๊ฐ ํ ์ ์์ต๋๋ค.
fmod.asm : (64 ๋นํธ)
.code
fmod PROC
sub rsp , 18h
movsd QWORD PTR [rsp+8h] , xmm0
fld QWORD PTR [rsp+8h]
movsd QWORD PTR [rsp+8h] , xmm1
fld QWORD PTR [rsp+8h]
fxch st(1)
L1:
fprem
fstsw ax
sahf
jp L1
fstp st(1)
fstp QWORD PTR [rsp+8h]
movsd xmm0 , QWORD PTR [rsp+8h]
add rsp,18h
ret
fmod endp
end
masm ๋ช
๋ น : ml64.exe /c fmod.asm
fmod.obj
(ml64.exe์ 64 ๋นํธ ๋ณํ ์ฌ์ฉ)
``
objdump -D fmod.obj
....
Disassembly of section .text$mn:
0000000000000000 <fmod>:
0: 48 83 ec 18 sub $0x18,%rsp
4: f2 0f 11 44 24 08 movsd %xmm0,0x8(%rsp)
a: dd 44 24 08 fldl 0x8(%rsp)
e: f2 0f 11 4c 24 08 movsd %xmm1,0x8(%rsp)
14: dd 44 24 08 fldl 0x8(%rsp)
18: d9 c9 fxch %st(1)
1a: d9 f8 fprem
1c: 9b df e0 fstsw %ax
1f: 9e sahf
20: 7a f8 jp 1a <fmod+0x1a>
22: dd d9 fstp %st(1)
24: dd 5c 24 08 fstpl 0x8(%rsp)
28: f2 0f 10 44 24 08 movsd 0x8(%rsp),%xmm0
2e: 48 83 c4 18 add $0x18,%rsp
32: c3 retq
@carlkl ๊ฐ์ฌํฉ๋๋ค. OpenBLAS ํจ์๋ฅผ ํธ์ถํ๊ธฐ ์ ์ x86_64์์ ์ฌ์ฉํ ์์๋ ST (N) ๋ ์ง์คํฐ๋ฅผ ์ฌ์ค์ ํ๋ ์ด์
๋ธ๋ฌ์ ๋ ๋ง์กฑํ ๊ฒ์
๋๋ค. ์ค๋์ด ๋ฌธ์ ๋ fmod
์ ๋ณ๊ฒฝ์ผ๋ก ์ธํด ๋ฐ์ํ์ผ๋ฉฐ ๋ด์ผ์ ๋ค๋ฅธ ๊ธฐ๋ฅ์ด ๋ ์ ์์ต๋๋ค. ๋ฐํ์ ST(N)
๋ ์ง์คํฐ๋ฅผ ์ฌ์ค์ ํ๋ ๋ฐ ํจ์๊ฐ ํ์ํ์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๊ทธ๋ฌํ ์๊ตฌ ์ฌํญ์ด์๋ ๊ฒฝ์ฐ fmod
๋ ์ค์ ๋ก ๋ฒ๊ทธ๊ฐ ์์ผ๋ฉฐ Windows ๋ณ๊ฒฝ์ผ๋ก ์ธํด OpenBLAS์์ ๋ ์ง์คํฐ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ ์ ๋ ์ง์คํฐ๋ฅผ ์ฌ์ค์ ํ๋ ๋ฐ ์คํจํ์ฌ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ฑฐ๋ ํด๊ฒฐํ๋ ๋ฐ ๋์์ด๋ฉ๋๋ค.
์ ์ fldz
๋ฅผ ์ฌ์ฉํ์ฌ ๋ ์ง์คํฐ๋ฅผ ์ฌ์ค์ ํ๋ ค๊ณ ํ์ง๋ง ํ
์คํธ ํ๋ก๊ทธ๋จ์ด ์๋ํ์ง ์์ต๋๋ค.
@mattip , ๋ด ์ด์ ๋ธ๋ฌ knowlegde๋ ๋ค์ ๊ธฐ๋ณธ์ ์ ๋๋ค. ๊ทธ๋ฌ๋์ด SO ์ค๋ ๋์์ ๊ฐ๋ฅํ ๋ต๋ณ์ ์ฐพ์ ์ ์์ต๋๋ค. https://stackoverflow.com/questions/19892215/free-the-x87-fpu-stack-ia32/33575875
https://docs.microsoft.com/de-de/cpp/build/x64-calling-convention?view=vs-2019์์ :
The x87 register stack is unused. It may be used by the callee, but consider it volatile across function calls.
OpenBLAS nrm2.S (PROFCODE ๋งคํฌ๋ก ์ดํ) ์์์ fninit
๋ฅผ ํธ์ถํ์ฌ ํด๋น ์ด๋ก ์ ํ์ธํ ์๋ ์์ต๋๋ค.
์์ ํฅ๋ฏธ๋ก์ด ๋นํธ
System V ์ ํ๋ฆฌ์ผ์ด์
๋ฐ์ด๋๋ฆฌ ์ธํฐํ์ด์คAMD64 ์ํคํ
์ฒ ํ๋ก์ธ์ ๋ณด์ถฉ ์๋ฃ์ด์ ๋ฒ์ 0.99.6
_MXCSR ๋ ์ง์คํฐ์ ์ ์ด ๋นํธ๋ ์์ ์ ์ ์ฅ (ํธ์ถ ๋์ ๋ณด์กด ๋จ)์ด๊ณ ์ํ ๋นํธ๋ ํธ์ถ์ ์ ์ฅ (๋ณด์กด๋์ง ์์)์ ๋๋ค ._
_x87 ์ํ ์ด ๋ ์ง์คํฐ๋ ํธ์ถ์ ์ ์ฅ์ด๊ณ x87 ์ ์ด ์ด๋ ํธ์ถ์ ์ ์ฅ์ ๋๋ค ._
_ ๋ชจ๋ x87 ๋ ์ง์คํฐ๋ ํธ์ถ์ ์ ์ฅ๋๋ฏ๋ก MMX ๋ ์ง์คํฐ๋ฅผ ์ฌ์ฉํ๋ ํผ ํธ์ถ์๋ ๋ ๋น ๋ฅธ femms ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค ._
Windows 64 ๋นํธ ํธ์ถ ๊ท์น๊ณผ๋ ์๋นํ ๋ค๋ฆ ๋๋ค.
@ martin-frbg, fninit
๋ ์ํํฉ๋๋ค : The FPU control word is set to 037FH (round to nearest, all exceptions masked, 64-bit precision).
X87 ํ์ฅ ์ ๋ฐ๋๋ ๋ชจ๋ ๊ฒฝ์ฐ, ํนํ Windows์์ ์ํ๋ ๊ฒ์ ์๋๋๋ค.
๋น ๋ฅธ ํ ์คํธ๋ฅผ ์ํด ๋ฆด๋ฆฌ์ค ๋ฒ์ ์๋ ์ด๊ฒ์ ์ํ์ง ์์ต๋๋ค. OpenBLAS๊ฐ ์ด๋ป๊ฒ ๋ "์ด์ ์"์ ๋ฆฌ๋์ด์ผํ๋ค๊ณ ํ์ ํ์ง๋ ๋ชปํ์ง๋ง, ๋ ๊ฑฐ์ x87 fpu์ ๋ํ Windows ๋์์ ๋ํ ๋ช ํํ ๋ฌธ์๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค. Agner Fog๊ฐ http://www.agner.org/optimize/calling_conventions.pdf ์ ํธ์ถ ๊ท์น์ ๋ํ ๋ฌธ์๊ฐ ์์์ ์์์ต๋๋ค (FP ๋ ์ง์คํฐ์ Win64 ์ฒ๋ฆฌ์ ๋ํ ๋ ผ์๋ 13 ํ์ด์ง์์ ์์ํ์ง๋ง ์ปจํ ์คํธ ์ค์์น ์ ๋ฐ์ ๊ธฐ๋ณธ ๊ฐ์ฉ์ฑ ๋ฐ ๋์์ ์ค์ ์ ๋ก๋๋ค).
https://github.com/numpy/numpy/issues/16744#issuecomment -703305582๋ฅผ ์ฐธ์กฐ
The x87 register stack is unused. It may be used by the callee, but consider it volatile across function calls.
๋๋ ์ด๊ฒ์ด ์๋ฏธํ๋ค๊ณ ์๊ฐํฉ๋๋ค : x87 ๋ช ๋ น (Win64)์ ์ฌ์ฉํ์ง ๋ง์ญ์์ค. ๊ทธ๋ ๋ค๋ฉด ํ์ด์ ๋น๋๋ค. ์ฆ, ํผ ํธ์ถ์๋ ํผํด๋ฅผ ์ ์ง ์์ ์ฑ ์์ด ์์ต๋๋ค.
ํ ๊ทธ๊ฒ์ MSVC ์ปดํ์ผ๋ฌ์ ๋์์ ๊ตฌ์ฒด์ ์ผ๋ก ์ค๋ช ํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ ๋ ์ฐ๋ฆฌ๊ฐ mingw ์ํ๊ณ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
์๋์, Numpy (Pypi)๋ Windows์์ MSVC (Visual Studio 2019)๋ก ์ปดํ์ผ๋ฉ๋๋ค. OpenBLAS์ ๊ฒฝ์ฐ mingw-w64๊ฐ ์ฌ์ฉ๋ฉ๋๋ค (Fortran ๋ถํ์ผ๋ก ์ธํด). ๋ํ Scipy Fortran ๋ถ๋ถ์ mingw-w64๋ก ์ปดํ์ผ๋ฉ๋๋ค. ๊ทธ๋ฌ๋ CPython ๋ฐ ์ด์ง ํ์ฅ์ MSVC์์ ์ค์ ํ ํ์ค์ ๊ธฐ๋ฐ์ผ๋กํฉ๋๋ค.
BTW : ์ด๊ฒ์ด ํ์ฌ ๋ค์ ์ด์ ๋๊ณ ์๋ https://github.com/mingwpy ๊ฐ๋ฐ์ ์ด์ ์์ต๋๋ค. (๋ป๋ปํ ํ๋ฌ๊ทธ)
๋ ๋ค๋ฅธ ๋นํธ :
mingw-w64๋ MSVC์ ๊ฑฐ์ ๋์ผํ ํธ์ถ ๊ท์น์ ์ฌ์ฉํฉ๋๋ค. ์ฃผ๋ชฉํ ๋งํ ์ฐจ์ด์ ์ x86 (32 ๋นํธ)์์ ์๋ก ๋ค๋ฅธ ์คํ ์ ๋ ฌ์
๋๋ค. SIMD ๋ฐ ์ง์๋์ง ์๋ vectorcall
์์ต๋๋ค.
ํฅ๋ฏธ ๋กญ๊ตฐ. x86์ ์ํฅ์๋ฐ์ง ์์ต๋๋ค. AMD64 ๋ง.
Sun, Oct 4, 2020, 22:19 carlkl [email protected] ์์ฑ :
๋ ๋ค๋ฅธ ๋นํธ :
mingw-w64๋ MSVC์ ๊ฑฐ์ ๋์ผํ ํธ์ถ ๊ท์น์ ์ฌ์ฉํฉ๋๋ค. ์ ์ผํ
์ฃผ๋ชฉํ ๋งํ ์ฐจ์ด์ ์ x86 (32 ๋นํธ)์์ ์๋ก ๋ค๋ฅธ ์คํ ์ ๋ ฌ์ ๋๋ค.
SIMD ๋ฐ ์ง์๋์ง ์๋ ๋ฒกํฐ ํธ์ถ๊ณผ ๊ด๋ จ์ด ์์ต๋๋ค.โ
๋น์ ์ด ์ธ๊ธ ๋์๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ ๋ฐ๊ณ ์์ต๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ณ GitHub์์ ํ์ธํ์ธ์.
https://github.com/numpy/numpy/issues/16744#issuecomment-703317784 ๋๋
๊ตฌ๋ ์ทจ์
https://github.com/notifications/unsubscribe-auth/ABKTSRMFHWZVLDYDFGBM6YDSJDRGTANCNFSM4OP5IXNQ
.
MSVC 32bit๋ ์๋ง๋ fpu๋ฅผ ๋ถ์ธํ์ง ์์์๊น์? fpu-using nrm2.S๋ฅผ nrm2_see2.S (์คํ ๊ฐ๋ฅํ ๊ฒฝ์ฐ ๋ถํํ๋ ์ฝ๋๋ฒ ์ด์ค์ ๋ ๋ค๋๋ ์ฌ์ฉ๋์ง ์์ง๋ง ์น๋ช ์ ์ธ ์ด์ ๋ธ๋ฆฌ ๋ฃจํด์ด ๋ง์ด ์์) ๋๋ OS ์ฉ ์ผ๋ฐ C ๋ฒ์ ์ผ๋ก ์์ ์์ ๋์ฒด๋ฅผ ์ํ ํ ๊ฒ์ ๋๋ค. == Windows. (์ฌ๊ธฐ์ ๋ ผ์ ๋ ๋ค๋ฅธ ๋ฌธ์ ๋ x86_64์ ๋ํ ๋ค๋ฅธ ๋ชจ๋ ์ด์ ์ด์ ๋ธ๋ฆฌ ๋ฃจํด์ด ์ ์ด๋ SSE2๋ผ๊ณ ์๊ฐํ๋ฏ๋ก ๋ค๋ฅธ ๋ฌธ์ ์ฌ์ผํฉ๋๋ค.)
@mattip, ์ด์ฉ๋ฉด์๊ฒ ์ ํ _fpreset
ํ divmod
์
์๋ง FPU ์ํ์์ ์ฌ์ค์ ํ๊ธฐ์ ์ถฉ๋ถํ๋ค?
_fpreset
๋ํ ์ ํ
์๋์, ST(N)
๋ ์ง์คํฐ๋ฅผ ์ฌ์ค์ ํ์ง ์์ผ๋ฉฐ ์คํจํ ํ
์คํธ๋ฅผ ์์ ํ์ง๋ ์์ต๋๋ค.
_fninit
์๋ํด ๋ณด์
จ๋์? ๊ทธ๋ฌ๋ฉด FPU ์คํ์ด ์ฌ์ค์ ๋ฉ๋๋ค. ๋๋ https://stackoverflow.com/questions/19892215/free-the-x87-fpu-stack-ia32/33575875์ ์ธ๊ธ ๋๋๋ก fldz
๋์ ffree
๋๋ fstp
?
๊ธฐ๊บผ์ด ์ด์
๋ธ๋ฌ ๋ช
๋ น์ ์๋ํ์ง๋ง ์ ์ฃผ์์ ํ
์คํธ ํ๋ก์ ํธ๊ฐ ์ถฉ๋ํฉ๋๋ค. ๋๊ตฐ๊ฐ ๋ด ์ฝ๋๋ฅผ ์์ ํ์ฌ ์๋ํ๋๋กํด์ผํฉ๋๋ค (์ค์ ๋ก fninit
๊ฐ ์ข์ ํ๋ณด ์ธ ๊ฒ ๊ฐ์ต๋๋ค). ๊ทธ๋ฌ๋ฉด OpenBLAS๋ฅผ ํธ์ถํ๊ธฐ ์ ์ NumPy์์ ๋ ์ง์คํฐ๋ฅผ ์ฌ์ค์ ํ๋ ์ด์
๋ธ๋ฌ ๋ช
๋ น์ด๋ฅผ ๋ด๋ณด๋ผ ์ ์์ต๋๋ค.
์ด ๊ฐ์?
.code
reset_fpu proc
finit
fldz
reset_fpu endp
end
finit
ist wait
+ fninit
. fninit
์ดํ์ fldz
๊ฐ ํ์ํ์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
์ฃผ์์์ ๋งํ๋ฏ์ด ์ปดํ์ผ ๋ ์ด์
๋ธ๋ฆฌ ์ฝ๋์ ๋ํ ํธ์ถ์ด ์ฌ๋ฐ๋ฅด๊ฒ ์๋ํ๋๋กํ๊ธฐ ์ํด ๋๋ฝ ๋ ๊ฒ์ด ์์ต๋๋ค. ์ด๊ฒ์ ๋ด๊ฐ ๊ทธ ์ฝ๋ฉํธ์์ ๊ฐ์ง ๊ฒ์
๋๋ค. ์ฝ๋๊ฐ exited with code -2147483645
์ ์ถฉ๋ํฉ๋๋ค. ์ ์ฒด ์ฝ๋๋ฅผ ์ดํด๋ณด๊ณ ์ ๋๋ก ์๋ํ๋์ง ํ์ธํ์ญ์์ค.
๋๋ ๊ทธ๊ฒ์ ์๋ ํ ์์๋ค (๋ด์ผ). ๊ทธ๋ฌ๋์ด ์ค ๋ํซ์ด ๋์์ด ๋ ์ ์์ต๋๋ค.
https://www.website.masmforum.com/tutorials/fptute/fpuchap4.htm
(๋ด๊ฐ ์ฐพ์์ด ์ฃผ์ ์ ๋ํด ๊ฐ์ฅ ์ฝ๊ธฐ ์ฌ์ด ์ฌ์ดํธ ์ค ํ๋)
FLDZ (Load the value of Zero)
Syntax: fldz (no operand)
Exception flags: Stack Fault, Invalid operation
This instruction decrements the TOP register pointer in the Status Word
and loads the value of +0.0 into the new TOP data register.
If the ST(7) data register which would become the new ST(0) is not empty, both
a Stack Fault and an Invalid operation exceptions are detected, setting both flags
in the Status Word. The TOP register pointer in the Status Word would still
be decremented and the new value in ST(0) would be the INDEFINITE NAN.
A typical use of this instruction would be to "initialize" a data register intended
to be used as an accumulator. Even though a value of zero could also be easily
loaded from memory, this instruction is faster and does not need the use of memory.
๋ด๊ฐ ์ดํดํ๋ฏ์ด st (7)์ด ์ฌ์ฉ ์ค์ด๋ฉด fldz๊ฐ segfault๋ฅผ ์ํ ํ ์ ์์ผ๋ฏ๋ก ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
FFREE (Free a data register)
Syntax: free st(x)
This instruction modifies the Tag Word to indicate that the specified 80-bit data register
is now considered as empty. Any data previously in that register becomes unusable.
Any attempt to use that data will result in an Invalid exception being detected and an
INDEFINITE value possibly being generated.
Although any of the 8 data registers can be tagged as free with this instruction,
the only one which can be of any immediate value is the ST(7) register when
all registers are in use and another value must be loaded to the FPU.
If the data in that ST(7) is still valuable, other instructions should be used
to save it before emptying that register.
์๋ํด ๋ณผ ์ ์์ต๋๋ค.
.code
reset_fpu proc
ffree st(7)
fldz
reset_fpu endp
end
๋ช
ํํ์ง ์์์ ์ฃ์กํฉ๋๋ค. ์ฆ๊ฐ์ ์ธ ๋ฌธ์ ๋ ์ด์
๋ธ๋ฌ๊ฐ ํธ์ถ ํ๋ ๊ฒ์ด ์๋๋๋ค. ์ฆ๊ฐ์ ์ธ ๋ฌธ์ ๋ ์ ๋๋ก ์ฐ๋ฆฌ๊ฐ ๊ทธ๊ฒ์ ์ฌ์ฉํ ์์๋ ๋ฐฉ๋ฒ์ผ๋ก ํธ์ถ ํ๋ก ์์ ๋ฅผ ์์ฑํ๊ณ , ๋ ํ์ผ์์ ํด๋น (์ฆ๋ช
ํ๋ ๋ฐฉ๋ฒ์ *.asm
๋ฐ main.c
/ main.cpp
) ์ปดํ์ผ ๋ฐ ์คํ๋๋ ํ๋ก์ ํธ. ๊ทธ๋ฐ ๋ค์ ์ฌ๋ฌ ํธ์ถ์ด OpenBLAS์ ์ด๋ป๊ฒ ์ํฅ์ ๋ฏธ์น๋์ง ๊ณ์ ํ์ ํ ์ ์์ต๋๋ค.
@mattip , ์ดํดํฉ๋๋ค. ๋๋ ํ์คํ ๊ทธ๊ฒ์ ์๋ ํ ๊ฒ์ด์ง๋ง ์ด๊ฒ์ ์๊ฐ์ด ๊ฑธ๋ฆด ์ ์์ต๋๋ค.
๋๋ UCRT์์ FMOD์ _tempory_ ๋์ ํ๋์ด OpenBLAS์ ์ํด _healed_ํด์ผ ์ธ์์ ๊ฐ์ง๊ณ : https://github.com/xianyi/OpenBLAS/pull/2882์ ํ์ง WIN64์์ FPU๋ฅผ ์ฌ์ฉํ์ง ์๋ NumPy์ ๊ฐ์ NumPy์์ ์ํด. ๋ฌผ๋ก MS๋ Windows ํจ์น๋ก์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํด์ผํฉ๋๋ค.
์ด ๊ฒฝ์ฐ numpy ํจ์น๋ ๋น๋ ์ค์ ๋ค๊ฐ์ค๋ OpenBLAS ๋ฆด๋ฆฌ์ค๋ณด๋ค ์ค๋๋์ง ์์ OpenBLAS ๋ฒ์ ์ ์ฌ์ฉํ๋๋ก ๋ณด์ฅํ๋ ๊ฒ์
๋๋ค.
@matti numpy/__init__.py
์จ ์ ์ฑ ๊ฒ์ฌ๊ฐ ์์ต๋๋ค. ์ด ๋ฌธ์ ๋ฅผ ๊ฐ์งํ๊ธฐ ์ํด ์ถ๊ฐ ํ ์์๋ ๊ฐ๋จํ๊ณ ์ ๋ขฐํ ์์๋ ํ
์คํธ๊ฐ ์์ต๋๊น?
a = np.arange(13 * 13, dtype=np.float64).reshape(13, 13)
a = a % 17
va, ve = np.linalg.eig(a)
@mattip , ์ค ๋ํซ ๊ฐ์ฌํฉ๋๋ค. ํ์ง๋ง ์ด๋ฌํ ์ข ๋ฅ์ ํ ์คํธ๋ฅผ ์ํ ํ ์์๋ ๋ฐ์คํฌํฑ์ ์ก์ธ์คํ๋ ค๋ฉด ์๊ฐ์ด ํ์ํฉ๋๋ค. ์ง๊ธ์ ๊ฑฐ์ ์๋ฌด๊ฒ๋ ์ค์นํ ์์๋ ์ต์ํ์ ํ๋ก๊ทธ๋๋ฐ ํ๊ฒฝ์ ๊ฐ์ถ ๋ฉํฑ์ผ๋ก ๋๋ถ๋ถ์ ์๊ฐ์ ์์ ํ๊ณ ์์ต๋๋ค.
OpenBLAS v0.3.12์ ๋ํ ์ ๋ฐ์ดํธ๋ฅผ ๋ณํฉํ์ผ๋ฉฐ ํด๋น ๋ฒ์ + Windows ์ ๋ฐ์ดํธ 2004๋ฅผ ์ฌ์ฉํ๋ ๋ก์ปฌ ๋น๋๊ฐ ํ ์คํธ ์ค์ํธ๋ฅผ ํต๊ณผํ์ต๋๋ค.
Windows๊ฐ ์ ๋ฐ์ดํธ ๋ ๋๊น์ง ์ด์ด ๋ก๋๋ค.
์ถ์ ์ ํ ์ด ์๋ก์ด OpenBLAS๋ก ์ ์ ๋์์ต๋๊น? ์ด ๋ฒ๊ทธ๊ฐ ๋ฐ์ํ ๋ค์ด ์คํธ๋ฆผ ํ๋ก์ ํธ์ ๋ํ ์ถ๊ฐ ํ ์คํธ๋ฅผ ์ํํ๊ฒ๋์ด ๊ธฐ์ฉ๋๋ค.
ํ ์คํธ ์ค๋ฅ๊ฐ ์์๊ธฐ ๋๋ฌธ์ Windows 3.9 ์ํํ ํ ์ด ํ์ฌ ๋๋ฝ๋์์ต๋๋ค (ํ์ฌ ์์ ๋จ). ๊ณ ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ์ค๋ ๋๋ ๋ด์ผ ๋์ฌ 1.19.3์์ ์ฌ์ฉ๋ฉ๋๋ค.
/MT
์ต์
์ Windows์์ ์ ์ ๋งํฌ๋ฅผ ํ์ฑํํฉ๋๋ค. 1909 ๋ฒ์ ์ Microsoft SDK๋ฅผ ์ฌ์ฉํ์ฌ libucrt.lib์ ๋ํด ์ ์ ์ผ๋ก ๋งํฌ ํ ์ ์์ต๋๋ค. ์ด๊ฒ์ 2004 ๋
๊ณผ 20H2์ ucrtbase.dll ๋ฒ๊ทธ์ ๋ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ผ๋ก ์์ฉํ ์ ์์ต๋๋ค. ๊ทธ๊ฒ์ ๋ฐํด๋ฅผ ๋ ํฌ๊ฒ ๋ง๋ค ๊ฒ์
๋๋ค. ์ด๊ฒ์ ๋จ์ ์
๋๋ค.
์ด / MT ๋ฌธ์ ๊ฐ ์ฌ์ ํ ์ ํจํ์ง ๋ชจ๋ฅด๊ฒ ์ง๋ง ๊ณ ๋ คํด์ผํฉ๋๋ค.
NumPy๊ฐ MT๋ก ๋น๋๋๋ ์ ์ผํ ๋ชจ๋์ด๋ผ๋ฉด
ํ์ธ. ๋ฌผ๋ก NumPy๊ฐ MT์ด๋ฉด
๋ค์ด ์คํธ๋ฆผ๋ MT ์ฌ์ผํ๋ฏ๋ก ๋ฌธ์ ๊ฐ๋ฉ๋๋ค.
2020 ๋ 11 ์ 2 ์ผ ์์์ผ 19:37 carlkl [email protected] ์์ฑ :
์ด / MT ๋ฌธ์ ์ธ์ง ๋ชจ๋ฅด๊ฒ ์ด์
https://stevedower.id.au/blog/building-for-python-3-5-part-two ๋ ์ฌ์ ํ
์ ํจํ์ง๋ง ๊ณ ๋ คํด์ผํฉ๋๋ค.โ
๋น์ ์ด ์ธ๊ธ ๋์๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ ๋ฐ๊ณ ์์ต๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ณ GitHub์์ ํ์ธํ์ธ์.
https://github.com/numpy/numpy/issues/16744#issuecomment-720682011 ๋๋
๊ตฌ๋ ์ทจ์
https://github.com/notifications/unsubscribe-auth/ABKTSRJIVAQLECK4E2EVSSDSN4C65ANCNFSM4OP5IXNQ
.
์ด ๋ฌธ์ ์ ๋ํด ๊ถ์ฅ๋๋ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๊น? ๋ด ์ํฉ์ ๋ด๊ฐ 2004 ์ ๋ฐ์ดํธ๋ก ์ ๋ฐ์ดํธ ๋ ์ปดํจํฐ์ ์๊ณ pip๋ฅผ ์ฌ์ฉํ์ฌ numpy / scipy / pandas ๋ฑ์ ์ค์นํ๋ ๋ฐ์คํฌํฑ ์ํํธ์จ์ด๊ฐ ์๋ค๋ ๊ฒ์ ๋๋ค.์ด ๋ชจ๋ ์ํํธ์จ์ด๋ Microsoft ์ ๋ฐ์ดํธ๋ก ์ธํ์ด ๋ฌธ์ ์ ์ํฅ์๋ฐ์ต๋๋ค.
conda๋ฅผ ์ฌ์ฉํ์ฌ numpy๋ฅผ ์ค์นํ๋ ๊ฒ์ ๋ด๊ฐ ์์ ์ค์ธ ์ํํธ์จ์ด์ ๋ํ ์ต์ ์ด ์๋๊ธฐ ๋๋ฌธ์ ๋ชจ๋ ๊ถ์ฅ ์ฌํญ์ ์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค.
๋ ์ปค๊ฐ ํ์ํ์ง ์์ ๊ฒฝ์ฐ 1.19.3์ ๊ณ ์ ํ ์ ์์ต๋๋ค. ๋ด Windows ์์คํ ์ ๋ชจ๋ ํ ์คํธ๋ฅผ ํต๊ณผํ์ต๋๋ค.
๊ฐ์ฌ. 1.19.3์ ๋ฌธ์ ์ ๋ํด pip์ ํจ๊ป ์๋ํฉ๋๋ค.
์๋ชป๋ BLAS ๊ฐ์ง์ ๋งํฌ๋ MS ์ฌ์ดํธ์ ๋ง์ ์๋๋ฌ์ด ๊ฒ์๋ฌผ์ ์ ๋ํ๊ณ ์์ต๋๋ค. ๋๋ ์ด๊ฒ์ด ๊ฒฐ๊ตญ ํญ๋ฐํ์ง ์๊ธฐ๋ฅผ ๋ฐ๋๋๋ค.
๋ ๋ค๋ฅธ ๋์์ Win64์์ ํ์ฌ fmod๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋๋ค.
NumPy๊ฐ ์ถ์ ํ 4 ๊ฐ์ ๋์ ์ด๋ ๊ฒ ์ฌ๊ฐํ ๋ฒ๊ทธ๊ฐ ์์ ๋์ง ์์ ๊ฒฝ์ฐ, ํนํ ์ฌ์ฉ์๊ฐ ์ด์ ๋ฒ์ ์ผ๋ก ๋ค์ด ๊ทธ๋ ์ด๋ ํ ์์๋ ๋ช ํํ ์ง์นจ์ ์ ๊ณตํ์ง ์์ ๊ฒฝ์ฐ ์๋ต์ด ์ด๋ป๊ฒ ๋ ์ง ๊ถ๊ธํฉ๋๋ค. ์ฌ์ฉ์๋ 1.19.3์ ์ฝ๊ฒ ๊ณ ์ ํ ์ ์์ง๋ง ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์ง๋ ์์ต๋๋ค. ๋ ์ง์คํฐ๊ฐ ์๋ง์ด ๋ ํ ๋ ์ง์คํฐ๋ฅผ ์ฌ์ฉํ๋ ๋ค๋ฅธ ํจํค์ง๋ก๋ง ์ด๋ํ ๊ฒ์ ๋๋ค.
ํด๊ฒฐ ๋ฐฉ๋ฒ์ ๋ํ ๋ ๋ค๋ฅธ ์์ด๋์ด : ucrt์ FPU๋ฅผ ์ฌ์ฉํ๊ณ ์ํ๋ฅผ ์ํธํ ์ํ๋ก ์ ์งํ๋ ๋ค๋ฅธ ๊ธฐ๋ฅ์ด ์๋์ง ํ์ธํฉ๋๋ค. ํ๋๊ฐ ์๋ค๋ฉด fmod ๋ค์์ ์ด๊ฒ์ ํธ์ถ ํ ์ ์์ต๋๋ค. ํน์ ํ์ผ์ด๋ ๋น๋ ํ๋ก์ธ์ค๊ฐ ํ์ํ์ง ์๊ธฐ ๋๋ฌธ์ @mattip์ด ์์ฑํ ์ด์ ๋ธ๋ฆฌ ํด๊ฒฐ ๋ฐฉ๋ฒ๋ณด๋ค ์ด์ ์ด ์์ต๋๋ค.
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ๋ ๋ง์ ๋
ธ๋ ฅ์ ๊ธฐ์ธ์ฌ์ผํ๋ค๊ณ ์๊ฐํ์ง ์์ต๋๋ค. ๋ฌธ์ ๋ฅผ ์ํํ๊ธฐ ์ํด ์ฐ๋ฆฌ๊ฐ ์ํํ๋ ๋ชจ๋ ์ถ๊ฐ ์์
์ ๊ท์คํ ๊ฐ๋ฐ์ ์๊ฐ์ ์ฐจ์งํ๊ณ Microsoft๊ฐ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํด์ผํ๋ ๋ถ๋ด์ ์ค์ฌ์ค๋๋ค. ๋ํ ์์์ ์ธ๊ธํ๋ฏ์ด fmod
๋ฅผ ํธ์ถํ๊ฑฐ๋ ๋ ์ง์คํฐ๋ฅผ ์ฌ์ฉํ๋ ๋ค๋ฅธ ํ๋ก์ ํธ์ ์ฝ๋๋ NumPy์ ์ฐ๊ฒฐํ์ง ์๊ณ ๋์ด ๋ฌธ์ ์ ๋ถ๋ช ํ ์ ์์ต๋๋ค.
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ๋ ๋ง์ ๋ ธ๋ ฅ์ ๊ธฐ์ธ์ฌ์ผํ๋ค๊ณ ์๊ฐํ์ง ์์ต๋๋ค. ๋ฌธ์ ๋ฅผ ์ํํ๊ธฐ ์ํด ์ฐ๋ฆฌ๊ฐ ์ํํ๋ ๋ชจ๋ ์ถ๊ฐ ์์ ์ ๊ท์คํ ๊ฐ๋ฐ์ ์๊ฐ์ ์ฐจ์งํ๊ณ Microsoft๊ฐ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํด์ผํ๋ ๋ถ๋ด์ ์ค์ฌ์ค๋๋ค. ๋ํ ์์์ ์ธ๊ธํ๋ฏ์ด
fmod
๋ฅผ ํธ์ถํ๊ฑฐ๋ ๋ ์ง์คํฐ๋ฅผ ์ฌ์ฉํ๋ ๋ค๋ฅธ ํ๋ก์ ํธ์ ์ฝ๋๋ NumPy์ ์ฐ๊ฒฐํ์ง ์๊ณ ๋์ด ๋ฌธ์ ์ ๋ถ๋ช ํ ์ ์์ต๋๋ค.
์ค๋ฅ ๋ฉ์์ง์ ๋ํ ๋ฐ์์ ๋ณด์์ ๋ ๊ทธ๋ค์ง ๋์์ด๋์ง ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ์ต์ NumPy ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ ค๋ Windows ์ฌ์ฉ์๋ ํ ํ ์ด ์๋ MKL๊ณผ ํจ๊ป ์ ๊ณต๋๋ ๋ฐฐํฌํ์ ์ฌ์ฉํด์ผํ๋ค๊ณ ์ ์ํด์ผํฉ๋๋ค. ์ด ์ค๋ ๋์ ๋ํ ๋งํฌ๋ ํฌํจ๋์ด์ผํฉ๋๋ค.
์ด๊ฒ์ ๋ถ๋ช ํ MS์ ์ฑ ์์ด์ง๋ง, ์ฌ์ฉ์๊ฐ ๋ค๋ฅธ ์ฌ๋์ ์๋ชป์ ์ง์ ํ๋๋ก ๊ณ ํต์์ฃผ๋ ๊ฒ์ ํ๋ก์ ํธ๊ฐ ์ ์๋ฅผ ์ ์งํ๋ ์ข์ ๋ฐฉ๋ฒ์ด ์๋๋๋ค.
@bashtage ๊ณ ํต์ ์ ๋ฐํ๋ ๊ฒ์ ๋ํด ๋ฌด์์ ์๋ฏธํ๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๋งํฌ๋ฅผ ์ ๊ฑฐํ๊ณ ์ฌ์ฉ์๊ฐ ์ฌ๊ธฐ์ ์ค๋๋ก ํ ์ ์์ง๋ง, 2004 ๋ ์ ์คํ๋ ๋ ๊ฒฐ๊ณผ๋ฅผ ์ ๋ขฐํ ์ ์์ผ๋ฉฐ ๊ณ์ฐ ๊ฒฐ๊ณผ๋ฅผ ์ ๋ขฐํ ์์๋ ๊ฒฝ์ฐ ํด๋น ํ๋ซํผ์์ ๊ณ์ฐ์ ํผํด์ผ ํจ์ ์ฌ์ฉ์์๊ฒ ๊ฒฝ๊ณ ํด์ผํฉ๋๋ค.
ํต์ฆ์ ์ ๋ฐํ๋ค๋ ๊ฒ์ด ๋ฌด์จ ๋ป์ธ์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
NumPy ๊ฐ์ ธ ์ค๊ธฐ๊ฐ ๋์ ๋๊ฒ ์คํจํ๋ฉฐ ์ ๊ณต๋ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค. ์๋ ค์ง ํด๊ฒฐ ๋ฐฉ๋ฒ ๋ชฉ๋ก์ด ๋ช ํํ๊ฒ ํ์๋๋ฉด ๋๋ถ๋ถ์ ์ฌ์ฉ์์๊ฒ ๊ฐ์ฅ ์ ์ฉํฉ๋๋ค.
(a) conda ๋๋ Enthought Deployment Manager์ ๊ฐ์ MKL ๊ธฐ๋ฐ ๋ฐฐํฌ๋ฅผ ์ฌ์ฉํ์ฌ์ด๋ฅผ ๋ฐฉ์งํ์ง๋ง ์ ํ ๋์ ์ฝ๋์์
(b) ๋ฒ๊ทธ๋ก๋ถํฐ ๋ณดํธ๋๋ OpenBLAS ๋ฒ์ ๊ณผ ํจ๊ป ์ ๊ณต๋๋ NumPy 1.19.3์ผ๋ก ๋๋๋ฆฝ๋๋ค. ์ด ์ต์
์ ์ปจํ
์ด๋์์ ์คํ์ค์ธ ์ฌ์ฉ์์๊ฒ๋ ์ ํฉํ์ง ์์ ์ ์์ต๋๋ค.
(c) ์์ค์์ ๋น๋ํฉ๋๋ค. ์ด ์ต์
์ ์ฑ๋ฅ์ด ๋ฎ์ BLAS๋ฅผ ๊ฐ์ง๋ง ํ์ฌ ๋ฐฐํฌ๊ฐ ํ์ฉ๋์ง ์๊ณ ์ปจํ
์ด๋๊ฐ ์ฌ์ฉ๋๊ฑฐ๋ NumPy์ ์ต์ ๊ธฐ๋ฅ ๋๋ ๋ฒ๊ทธ ์์ ์ด ํ์ํ ํ๊ฒฝ์ ์ ํฉ ํ ์ ์์ต๋๋ค.
๋๋ fmod ๋ฒ๊ทธ์ ๋ํด์ฃผ์๋ฅผ ํ๊ธฐ์ํค๋ ๊ฒ์ด ์๋ชป์ด๋ผ๊ณ ์๊ฐํ์ง ์์ง๋ง, ๋ง์น ํด๊ฒฐ์ฑ ์ด ๊ธฐ๋ค๋ฆฌ๊ณ ์๋ ๊ฒ์ฒ๋ผ ์ฌ์ฉ์๋ฅผ ํด๋น ํฌ๋ผ์ผ๋ก ๋ณด๋ ๋๋ค.
๋งํฌ๋ฅผ ์ ๊ฑฐํ๊ณ ์ฌ์ฉ์๊ฐ ์ฌ๊ธฐ์ ์ค๋๋ก ํ ์ ์์ง๋ง, 2004 ๋ ์ ์คํ๋ ๋ ๊ฒฐ๊ณผ๋ฅผ ์ ๋ขฐํ ์ ์์ผ๋ฉฐ ๊ณ์ฐ ๊ฒฐ๊ณผ๋ฅผ ์ ๋ขฐํ ์์๋ ๊ฒฝ์ฐ ํด๋น ํ๋ซํผ์์ ๊ณ์ฐ์ ํผํด์ผ ํจ์ ์ฌ์ฉ์์๊ฒ ๊ฒฝ๊ณ ํด์ผํฉ๋๋ค.
์ด๊ฒ์ ์ ํ ์ฌํญ์ด ์๋๋๋ค. ์ฌ์ฉ์๋ NumPy + OpenBLAS (์ : 0.3.12) ๋ง ํผํ๋ฉด๋ฉ๋๋ค. NumPy + Windows (2004 / 20H2 (ํ์ฌ 2 ๊ฐ์ ๋ฆด๋ฆฌ์ค ๋ ๋ฒ์ ์ด ์ํฅ์ ๋ฐ์))๋ฅผ ํผํ ํ์๊ฐ ์์ต๋๋ค.
MKL ๊ธฐ๋ฐ ๋ฐฐํฌ
MKL์ ๋ฌธ์ ๊ฐ ์๋ค๋๋ณด๊ณ ๋์์์ต๋๋ค.
NumPy 1.19.3์ผ๋ก ๋๋๋ฆฌ๊ธฐ
๊ทธ๋ฌ๋ fmod ์ฌ์ฉ์ผ๋ก ์ธํ ๋ค๋ฅธ ์ ์ฌ์ ์ธ ๋ฌธ์ ๋ ํด๊ฒฐ๋์ง ์์ต๋๋ค. ๋ฌธ์ ๋ ๊ฒฐ๊ณผ๊ฐ ์ ํํ์ง ํ์ธํ ๋ฐฉ๋ฒ์ด ์๋ค๋ ๊ฒ์ ๋๋ค.
์ฌ๋๋ค์ 2004 ๋ ์ Python์ ์ฌ์ฉํด์๋ ์๋๋ฉฐ, ๋์ WSL์ ์ฌ์ฉํ ์ ์์ต๋๊น? ๊ฐ๋ฅํ๋ค๋ฉด ์๋์ฐ ํ ์ด์๋ ์ค๋๋ ucrt๋ฅผ ํฌํจํด๋ ๊ด์ฐฎ๊ฒ ์ง ๋ง ๋ค๋ฅธ ํ๋ก์ ํธ๋ ์ด๋ป์ต๋๊น? ์ด์ Windows ๋ฒ์ ์ผ๋ก ๋์๊ฐ๋ ์ฌ์ด ๋ฐฉ๋ฒ์ด ์์ต๋๊น?
MKL์ ๋ฌธ์ ๊ฐ ์๋ค๋๋ณด๊ณ ๋์์์ต๋๋ค.
NumPy์๋ MKL์์ ์คํจํ ํ ์คํธ๊ฐ ์์ต๋๋ค. ๋ณด๊ณ ๋ ์ค๋ฅ๊ฐ ์๋๋ฐ ๋ฌธ์ ๊ฐ ์๋ค๊ณ ๊ฐ์ ํ๊ธฐ๋ ์ด๋ ต์ต๋๋ค. fmod ๋ฒ๊ทธ๋ MKL์ BLAS์ ๋ํ๋์ง ์์ต๋๋ค (์๋ง FPU๋ฅผ ์ฌ์ฉํ์ง ์๊ธฐ ๋๋ฌธ์).
๊ทธ๋ฌ๋ fmod ์ฌ์ฉ์ผ๋ก ์ธํ ๋ค๋ฅธ ์ ์ฌ์ ์ธ ๋ฌธ์ ๋ ํด๊ฒฐ๋์ง ์์ต๋๋ค. ๋ฌธ์ ๋ ๊ฒฐ๊ณผ๊ฐ ์ ํํ์ง ํ์ธํ ๋ฐฉ๋ฒ์ด ์๋ค๋ ๊ฒ์ ๋๋ค.
์๋์.ํ์ง๋ง Windows ๋ณด์ ๋ฌธ์ ๋ ๋ค๋ฅธ ๋ง์ ๋ฒ๊ทธ๋ ์์ ํ์ง ์์ต๋๋ค. ์ฌ๊ธฐ์ ๋ฌธ์ ๋ ๋งค์ฐ ํน๋ณํฉ๋๋ค.
์ด ๋ ๊ฐ์ง๋ ๊ฑฐ์ ๋ชจ๋ ์ฝ๋์์ ๋ฌธ์ ๊ฐ ๋๋ฌํ๊ธฐ ๋งค์ฐ ์ด๋ ต๋ค๋ ๊ฒ์ ๋์๊ฒ ์ ์ํฉ๋๋ค. OpenBLAS, ์์ผ๋ก ์์ฑํ ์ปค๋์ ํฌํจํ๋ FFT ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋๋ MKL๊ณผ ๊ฐ์ ์ต๊ณ ์ฑ๋ฅ ์ฝ๋ ๋ง # 2๋ฅผ ํธ๋ฆฌ๊ฑฐ ํ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค.
OpenBLAS 0.3.12๊ฐ ์์๋๋ก ์๋ํ๋ค๋ฉด NumPy๊ฐ ์ถ์๋์์ ๊ฒ์ด๊ณ ์ด ๋ฌธ์ ๋ ์ฌ์ฉ์์๊ฒ ์ ๊ธฐ๋์ง ์์์ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ ์์ ์ ์ถ์ํ๋ ๊ฒ์ด ํฉ๋ฆฌ์ ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
์ฌ๋๋ค์ 2004 ๋ ์ Python์ ์ฌ์ฉํด์๋ ์๋๋ฉฐ, ๋์ WSL์ ์ฌ์ฉํ ์ ์์ต๋๊น? ๊ฐ๋ฅํ๋ค๋ฉด ์๋์ฐ ํ ์ด์๋ ์ค๋๋ ucrt๋ฅผ ํฌํจํด๋ ๊ด์ฐฎ๊ฒ ์ง ๋ง ๋ค๋ฅธ ํ๋ก์ ํธ๋ ์ด๋ป์ต๋๊น? ์ด์ Windows ๋ฒ์ ์ผ๋ก ๋์๊ฐ๋ ์ฌ์ด ๋ฐฉ๋ฒ์ด ์์ต๋๊น?
๋ง์ ์ฌ์ฉ์๋ค์๊ฒ ์ด๊ฒ์ ๊ธฐ์ ๋ฐ์คํฌํฑ์ ๊ธฐ์ ์ฌ์ฉ์, ์ด๋ณด ํ์ (์ฝ ๋ค๋ฅผ ์ฌ์ฉํด์ผํ๋), ๋๋ ๋ค์ด ๊ทธ๋ ์ด๋ ํ ์์๋ 2004 ๋๋ 20H2 ๋ ธํธ๋ถ์ ๊ตฌ์ ํ ๋ชจ๋ ์ฌ์ฉ์์๊ฒ ์ค์ ๋ก ์ ํ ์ฌํญ์ด ์๋๋ผ๊ณ ์๊ฐํฉ๋๋ค.
Condas numpy๋ MLK์ ๋งํฌ๋์ด์์๋ฟ๋ง ์๋๋ผ ์ด์ ๋ฒ์ (10.0.17134.12) ์ธ ๊ฒ์ผ๋ก ๊ฐ์ฃผ๋๋ ์์ฒด ๋ฒ์ ์ธ ucrtbase.dll
๋ ์ด๋ฏธ ์ ๊ณตํ๊ณ ์์ต๋๋ค.
์ฌ๊ธฐ์์ @bashtage์ ํฌ๊ฒ ๋์ํฉ๋๋ค. ํฉ๋ฆฌ์ ์ธ ๊ถ์ฅ ์ฌํญ์ด์๋ ๊ฐ์ ธ ์ค๊ธฐ ์คํจ๋ ์ฌ์ฉ์์๊ฒ ์ฝ๊ฐ ์ ๋์ ์ ๋๋ค (Microsoft์ ๋ํ ์ฃผ์ ๊ฒฐํจ์๋ ๋ถ๊ตฌํ๊ณ ).
@jenshnielsen : Condas numpy๊ฐ MLK์ ๋ํด ๋งํฌ๋์ด์์๋ฟ๋ง ์๋๋ผ [...]
conda-forge์ ์ํด ํจํค์ง ๋ ๋น๋๋ blas / lapack ๊ตฌํ (openblas / mkl / blis / netlib์์)์ ์ ํ ํ ์ ์๋๋ก ํ์ฉํ์ง๋ง MKL์ด _have_๋ ๊ฒ์ ์๋๋๋ค.
์ฌ๋๋ค์ 2004 ๋ ์ Python์ ์ฌ์ฉํด์๋ ์๋๋ฉฐ, ๋์ WSL์ ์ฌ์ฉํ ์ ์์ต๋๊น?
์ด๋ ๋๋ถ๋ถ์ ์ฌ์ฉ์์๊ฒ ๊ธฐ๋ณธ ์๋ ๋ชจ๋๊ฐ ์๋๋๋ค.
๊ฐ๋ฅํ๋ค๋ฉด ์๋์ฐ ํ ์ด์๋ ์ค๋๋ ucrt๋ฅผ ํฌํจํด๋ ๊ด์ฐฎ๊ฒ ์ง ๋ง ๋ค๋ฅธ ํ๋ก์ ํธ๋ ์ด๋ป์ต๋๊น?
๋ค๋ฅธ ํ๋ก์ ํธ๋ ์ฐ๋ฆฌ์ ์ฑ ์์ด ์๋๋๋ค.
์ด์ Windows ๋ฒ์ ์ผ๋ก ๋์๊ฐ๋ ์ฌ์ด ๋ฐฉ๋ฒ์ด ์์ต๋๊น?
์๋ก ์ค์นํ๊ฑฐ๋ ๋์คํฌ ๊ณต๊ฐ์ ์ ๋ฆฌํ๋ค๋ฉด ๊ฑฐ์ ๋ถ๊ฐ๋ฅ ํด์ง๋๋ค.
์ฌ๊ธฐ์์ @bashtage์ ํฌ๊ฒ ๋์ํฉ๋๋ค. ํฉ๋ฆฌ์ ์ธ ๊ถ์ฅ ์ฌํญ์ด์๋ ๊ฐ์ ธ ์ค๊ธฐ ์คํจ๋ ์ฌ์ฉ์์๊ฒ ์ฝ๊ฐ ์ ๋์ ์ ๋๋ค (Microsoft์ ๋ํ ์ฃผ์ ๊ฒฐํจ์๋ ๋ถ๊ตฌํ๊ณ ).
๋๋ ๋์ํ๋ค. ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ง ์์ผ๋ฉด ๋ง์ ์ฌ์ฉ์๋ฅผ ์์ ์ ์์ต๋๋ค.
๊ฐ๋ฅํ๋ค๋ฉด ์๋์ฐ ํ ์ด์๋ ์ค๋๋ ucrt๋ฅผ ํฌํจํด๋ ๊ด์ฐฎ๊ฒ ์ง ๋ง ๋ค๋ฅธ ํ๋ก์ ํธ๋ ์ด๋ป์ต๋๊น?
@charris , Windows 10์์๋ ๋์์ด๋์ง ์์ต๋๋ค. python ๋๋ numpy์ ํจ๊ป ๋ค๋ฅธ ucrt๋ฅผ ๋ฐฐํฌํ๋ฉด Windows 10์์๋ก๋ ๋์ง ์์ต๋๋ค .์ด ๋ฐฉ๋ฒ์ ์ด์ Windows ๋ฒ์ (Windows 7, 8, 8.1)์๋ง ์ ์ฉ๋ฉ๋๋ค.
ํ
conda-packaged python์ ์ค์ ๋ก DLL ๊ฒ์ ๊ฒฝ๋ก ํ์ธ์ ๊ฐ์
ํฉ๋๋ค (๋ณ๊ฒฝ๋์ง ์์ ๊ฒฝ์ฐ-์๋ง๋ Windows 10์์ ์๋ํ์ง ์๋๋ค๊ณ ๋งํ๋ ์ด์ ์ผ ๊ฒ์
๋๋ค). ์ด๊ฒ์ AFAICT๊ฐ conda _does_๊ฐ ucrtbase.dll
์ ๊ณตํ๋ ์ด์ ์ด๊ธฐ๋ํฉ๋๋ค @jenshnielsen์ด ์ด ๊ฒ์ฒ๋ผ ucrtbase.dll
.
@ h-vetinari, Universal CRT ๋ฐฐํฌ๋ ๋ค์๊ณผ ๊ฐ์ด ๋ช ํํ๊ฒ ์ค๋ช ํฉ๋๋ค.
_ ๋ก์ปฌ ๋ฐฐํฌ์๋ ๋ ๊ฐ์ง ์ ํ ์ฌํญ์ด ์์ต๋๋ค.
Windows 10์์๋ ์์ฉ ํ๋ก๊ทธ๋จ์ ๋ฒ์ฉ CRT์ ์์ฉ ํ๋ก๊ทธ๋จ ๋ก์ปฌ ๋ณต์ฌ๋ณธ์ด ํฌํจ๋์ด ์๋๋ผ๋ ์์คํ
๋๋ ํฐ๋ฆฌ์ ๋ฒ์ฉ CRT๊ฐ ํญ์ ์ฌ์ฉ๋ฉ๋๋ค. Universal CRT๋ Windows 10์ ํต์ฌ ์ด์ ์ฒด์ ๊ตฌ์ฑ ์์์ด๊ธฐ ๋๋ฌธ์ ๋ก์ปฌ ๋ณต์ฌ๋ณธ์ด ๋ ์ต์ ์ธ ๊ฒฝ์ฐ์๋ ๋ง์ฐฌ๊ฐ์ง์
๋๋ค ._
BTW : ์ง์ ํ ์คํธํ์ต๋๋ค. Windows 10๊ณผ ํจ๊ป ๋ฐฐํฌ ๋ ์ฌ์ฉ ๊ฐ๋ฅํ UCRT ์ด์ธ์ ๋ค๋ฅธ UCRT๋ฅผ๋ก๋ ํ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
๋ํ ์์ ์ฌํญ์ ๋ฆด๋ฆฌ์คํ๋ ๊ฒ์ด ํฉ๋ฆฌ์ ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
์ด๊ฒ์ผ๋ก PR gh-17547์ ์ถ๊ฐํ๋ ๊ฒ์ ์๋ฏธํ๋ค๊ณ ์๊ฐํฉ๋๊น?
@carlkl ์ ์์ ์ฆ๋ช :
MS ์์ฒด์์ ๋ฐ์ํ๋์ด ๋ฒ๊ทธ๋ Heisenbug ๋ผ๊ณ ํฉ๋๋ค. ์์ธ์ ์ฐพ๋ ๊ฒ์ ๋น์ฉ์ด ๋ง์ด ๋ค๊ณ ์ด๋ ค์ ์ต๋๋ค. Windows 2004 UCRT fmod๋ ํน์ ์ํฉ์์ FPU ๋ ์ง์คํฐ๋ฅผ ์๋ชป๋ ์ํ๋ก ๋ก๋๋ค. ์ด๋ก ์ธํด ๋์ค์ FPU๋ฅผ ๋ค์ ์ฌ์ฉํ ๋ ์์น ๊ณ์ฐ ์ค๋ฅ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค. ์๊ฒฉํ๊ฒ ํ ์คํธํ์ง ์์ผ๋ฉด ์ผ๋ฐ์ ์ผ๋ก ๊ณ์ฐ ์ค๋ฅ๊ฐ ์ฌ์ฉ์ ์ฝ๋์ ๋ํ๋์ง ์์ต๋๋ค. ์ด๋ ์๋นํ ์์น ์ค๋ฅ๊ฐ ์ค๋ซ๋์ ๊ฐ์ง๋์ง ์์ ์ํ๋ก ๋จ์ ์์์ ์๋ฏธ ํ ์ ์์ต๋๋ค. ๋ ๋์ ์๋ ์์ต๋๋ค.
์ด๊ฒ์ผ๋ก PR gh-17547์ ์ถ๊ฐํ๋ ๊ฒ์ ์๋ฏธํ๋ค๊ณ ์๊ฐํฉ๋๊น?
์ฃ์กํฉ๋๋ค. ์ ๊ฐ ์๋ชป ์ผ์ต๋๋ค.
๋ด๊ฐ ์ ์ํ๋ ์ ์ผํ ๋ณ๊ฒฝ ์ฌํญ์ NumPy๊ฐ ๊ฐ์ ธ ์ค๊ธฐ์ ๋ฐ์ํ๋ ์์ธ์ ๋ ๋ง์ ์ ๋ณด๋ฅผ ์ ๊ณตํ์ฌ ์ฌ์ฉ์๊ฐ ์์ / ํ๊ต / ์ทจ๋ฏธ๋ฅผ ๊ณ์ํ ์์๋ Windows 2004 / H2 ํ๊ฒฝ์ ์ป์ ์์๋ ๋ฐฉ๋ฒ์ ์ ์ํ๋ค๋ ๊ฒ์ ๋๋ค.
[์ด ์์๋ ์๋ฃจ์ ์ ํ์ง์ ๋ํ ์ ํธ๋์ ๋๋ค.]
์ด ๋ฌธ์ ๋๋ ๋ ๊น์ ์ค๋ช ์ ์ ๊ณตํ๋ ์ข ๋ ๋ช ํํ ๋ฌธ์ ์ ์ฐ๊ฒฐํ๋ ๊ฒ๋ ์๋ฏธ๊ฐ ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ์ด ๋ ๋ฒ์งธ ๋งํฌ๋ github ๋ฌธ์ ๊ฐ ์๋ ๋ฌธ์์ ์ผ๋ถ ๋ฆด๋ฆฌ์ค ๋ ธํธ์ ๋ํ ๊ฒ์ผ ์๋ ์์ต๋๋ค.
conda-forge์ ์ํด ํจํค์ง ๋ ๋น๋๋ blas / lapack ๊ตฌํ (openblas / mkl / blis / netlib์์)์ ์ ํ ํ ์ ์๋๋ก ํ์ฉํ์ง๋ง MKL์ด _have_๋ ๊ฒ์ ์๋๋๋ค.
@ h-vetinari conda-forge + OpenBLAS๋ 2004 / H2์ ํต๊ณผ ํ ์คํธ๋ฅผ ๋น๋ํฉ๋๊น?
๋ฐฉ๊ธ ํ์ธํ๊ณ Coda-forge์์ OpenBlas 0.3.12๋ฅผ ๋ฐฐ์กํ์ต๋๋ค. ๊ทธ๋ฌ๋ฉด ์ปจํ ์ด๋๊ฐ ์ถฉ๋ํฉ๋๊น?
OpenBLAS-0.3.12์์ EMMS
๋ช
๋ น๊ณผ ํจ๊ป FPU ์ํ๋ฅผ ๋ณต๊ตฌํ๋ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ฉด ๋น์ฐํ numpy ๋ฐ scipy ํ
์คํธ๋ฅผ ์ ๋ฆฌํ๋ ๋ฐ ๋์์ด ๋ ์ ์์ง๋ง @charris๊ฐ fmod(0,x)
CPython ๋ฐ ๋์ค์ ํธ์ถ๋๋ FPU ๋ช
๋ น (OpenBLAS์ ๋ค๋ฅธ ํจํค์ง)๋ ๋ฐ์ํ ์ ์์ต๋๋ค. ์ด ๊ฒฝ์ฐ ๋ฌธ์ ๋ ๋ค๋ฅธ ๊ณณ์ผ๋ก ๋ง ์ด๋๋ฉ๋๋ค.
๊ฐ์ฅ ์ข์ ๋ฐฉ๋ฒ์ ์ค์ ๋ก MS๊ฐ ๋ฒ๊ทธ๊ฐ์๋ ๋์์ ํจ์นํ๋๋กํ๋ ๊ฒ์ ๋๋ค. Steve Dower๊ฐ ๋์ ์ค ์ ์์๊น์?
์ด๊ฒ์ Agner Fog ๋๋ Bruce Dawson์๊ฒ๋ ํฅ๋ฏธ๋ก์ด ์ด์ผ๊ธฐ๊ฐ ๋ ์ ์์ต๋๋ค. ๊ทธ์ ๋ธ๋ก๊ทธ์์์ด ๊ด๋ จ ์ด์ผ๊ธฐ๋ฅผ๋ณด์ญ์์ค.
์ค๋๋ ๋ชจ๋ ๊ฒ์ด ๋ค์ ์๋กญ๊ณ ์ปดํ์ผ๋ฌ ๋ฒ๊ทธ
์๋ง๋ OpenBlas 0.3.12์ ๋ฒ๊ทธ ์ผ ๊ฒ์ ๋๋ค. Private Bytes ์ด์ ์ ์ํ์ญ์์ค.
๋ ผ๋ฆฌ์ CPU๊ฐ 24 ๊ฐ์ด๋ฏ๋ก ๊ธฐ๋ณธ๊ฐ์ BLAS ์ค๋ ๋ 24 ๊ฐ์ ๋๋ค.
์ด๊ฒ์ conda-forge์ NumPy 1.19.2๊ฐ์๋ OpenBLAS 0.3.12์ ๋๋ค.
$env:OPENBLAS_NUM_THREADS=1
ํ๋ฉด ๋ํญ ๊ฐ์
$env:OPENBLAS_NUM_THREADS=4
์ค๋ ๋ :
@bashtage : OpenBLAS xianyi / OpenBLAS # 2970์์ OpenBLAS 0.3.12์ ๋ํด ๊ณ์ ๋ ผ์ ํ ์ ์์ต๋๊น?
@mattip conda + OpenBLAS๊ฐ ์ ๋ขฐํ ์์๋ ๋์์ธ์ง ํ์ธํ๋ ค๊ณ ํ์ต๋๋ค. ๋๋ 1.19.3์ด ์ด๋ฌํ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์์ ๋ ํด๊ฒฐํ๋ ๋ชจ๋ ๊ฒ์ ํด๊ฒฐํ๋ค๊ณ ์๊ฐํ์ง ์์ต๋๋ค.
@bashtage : @carlkl ์ ์์ ์ฆ๋ช :
conda-packaged python์ Windows ํ์ค DLL ํด์๋๋ฅผ ์ ๊ทน์ ์ผ๋ก ์ฐํํ๊ธฐ ๋๋ฌธ์ Windows ๋๊ตฌ๊ฐ ์ผ๋ง๋ ๋ง์ ์ฆ๊ฑฐ๊ฐ ๋ ์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ์๋ฅผ ๋ค์ด C:\Windows\System32
์ค๋๋ libcrypto.dll
์์์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค . ์๋ฅผ ๋ค์ด ํ์ญ์์ค. ๊ฐ๋จํ ๋งํด์, ๊ตฌ์ ์์คํ
๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ cryptography
ํ
์คํธ ์ค์ํธ์ ํ
์คํธ ์คํจ์ ์ํด์๋ง ์ ํ๋์์ผ๋ฉฐ, CONDA_DLL_SEARCH_MODIFICATION_ENABLE
์ฌ์ฉํ๋ฉด conda๊ฐ ์ ๊ณตํ๋ openssl์ ๊ฐ์ ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.
@bashtage : @ h-vetinari conda-forge + OpenBLAS๋ 2004 / H2์ ํต๊ณผ ํ ์คํธ๋ฅผ ๋น๋ํฉ๋๊น?
ํจํค์ง๋ฅผ ๋น๋ํ๋ CI๋ ์๋ง๋ ํ์ฌ ๋ฒ์ ์ด ์๋ ์ ์์ผ๋ฉฐ ์ง์ ๋น๋ํ๋ ๋ฐ ์ฝ๊ฐ์ ์๊ฐ์ด ๊ฑธ๋ ธ์ต๋๋ค. ์ ๋ ํ์ฌ 2004 ๋ ์ปดํจํฐ์์ ์คํ ์ค์ด๋ฉฐ ์ด๊ฒ์ ๋งค์ฐ ๊ธ์ ์ ์ธ ๊ฒฐ๊ณผ์ ๋๋ค ** :
= 10487 passed, 492 skipped, 19 xfailed, 1 xpassed, 227 warnings in 529.08s (0:08:49) =
@bashtage : ๋ฐฉ๊ธ ํ์ธํ๊ณ conda-forge์์ OpenBlas 0.3.12๋ฅผ ์ ๊ณตํ์ต๋๋ค. ๊ทธ๋ฌ๋ฉด ์ปจํ ์ด๋๊ฐ ์ถฉ๋ํฉ๋๊น?
conda-forge๋ ๊ณ ์ ๋ openblas ๋ฒ์ ๊ณผ ํจ๊ป ์ ๊ณต๋์ง ์์ต๋๋ค. blas ๋ฒ์ ์ "hotswap"(์ : openblas, mkl, blis ์ฌ์ด) ํ ์๋ ์์ผ๋ฏ๋ก ๋ฒ์ ์ด ํฐ ๋ฌธ์ ๊ฐ ์๋๋๋ค. ์ผ๋ฐ์ ์ผ๋ก ์ต์ ํจํค์ง ๋ฒ์ ์ ์ฌ์ฉํฉ๋๋ค. ์ถฉ๋์ด ์ปจํ ์ด๋ ๋ด์์ ์ฌํ๋๋์ง ์ฌ๋ถ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
@bashtage :: @mattip conda + OpenBLAS๊ฐ ์ ๋ขฐํ ์์๋ ๋์์ธ์ง ํ์ธํ๋ ค๊ณ ํ์ต๋๋ค. ๋๋ 1.19.3์ด ์ด๋ฌํ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์์ ๋ ํด๊ฒฐํ๋ ๋ชจ๋ ๊ฒ์ ํด๊ฒฐํ๋ค๊ณ ์๊ฐํ์ง ์์ต๋๋ค.
๋ฉ๋ชจ๋ฆฌ ์ฆ๊ฐ๋ xianyi / OpenBLAS # 2970์์ ์์ธํ ๋ ผ์ํ ๊ฒ์ฒ๋ผ openblas 0.3.12์ ๋ณ๊ฒฝ์ผ๋ก ์ธํ ๊ฒ์ ๋๋ค. ์ง๊ธ๊น์ง conda-forge๋ ์ ์๊ฒ ์ ๋ขฐํ ์์๋ ๋์์ผ๋ก ๋ณด์ ๋๋ค. ์ ์ด๋ ์ค๋ฅ์ ์ง์ ์ ์ธ ์ํฅ์๋ฐ์ง๋ ์์ต๋๋ค.
** ๋๋ ํ์ฌ์ ๋ง์คํฐ https://github.com/conda-forge/numpy-feedstock ์ ์ฌ์ฉํ๋๋ฐ, ์ด๊ฒ์ ์ฌ์ ํ โโ1.19.2์ ์๊ณ openblas 0.3.12์ ๊ฒฐํฉ๋์ด ์์ต๋๋ค. ์ฌ๋๋ค์ด ๊ด์ฌ์ด ์๋ค๋ฉด https://github.com/conda-forge/numpy-feedstock/pull/210 + openblas 0.3.12๋ฅผ ์ฌ์ฉํด ๋ณผ ์๋ ์์ต๋๋ค.
์ข์ ์์์ผ๋ก MS๋ VS ํฌ๋ผ์ ๋ค์ ๋์์ 2021 ๋ 1 ์ ๋ง๊น์ง ์์ ์ฌํญ์ด ๋์ฌ ์ ์๋ค๊ณ ์ ์ํ์ต๋๋ค.์ด ์ ๋ฐ์ดํธ๋ฅผ ๊ณ ๋ คํ ๋ ์ ์ผํ ์ง๋ฌธ์ ์ค๋ฅ ๋ฉ์์ง๋ฅผ ์ ๋ฐ์ดํธ ํ ๋ ๋ฐ์ํ๋ ์ค๋ฅ ๋ฉ์์ง๊ฐ ์๋์ง ์ฌ๋ถ์ ๋๋ค. ๋ฒ๊ทธ๊ฐ์๋ ๊ธฐ๋ฅ์ด ๊ฐ์ง๋์์ต๋๋ค.
conda-packaged python์ Windows ํ์ค DLL ํด์๋๋ฅผ ์ ๊ทน์ ์ผ๋ก ์ฐํํ๊ธฐ ๋๋ฌธ์ Windows ๋๊ตฌ๊ฐ ์ผ๋ง๋ ๋ง์ ์ฆ๊ฑฐ๊ฐ ๋ ์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๋๋ ๊ตฌ์์ผ๋ก, ์๋ฅผ ๋ค์ด์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค
libcrypto.dll
์์C:\Windows\System32
์ฐธ์กฐ ์๋ฅผ ๋ค์ด CONDA - ๋จ์กฐ๋ / # 11452๋ฅผ ๊ฐ์ต-์๋ฆฌ๋ฒ . ๊ฐ๋จํ ๋งํด์, ๊ตฌ์ ์์คํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋cryptography
ํ ์คํธ ์ค์ํธ์ ํ ์คํธ ์คํจ์ ์ํด์๋ง ์ ํ๋์์ผ๋ฉฐ,CONDA_DLL_SEARCH_MODIFICATION_ENABLE
์ฌ์ฉํ๋ฉด conda๊ฐ ์ ๊ณตํ๋ openssl์ ๊ฐ์ ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.
conda create -n cf -c conda-forge python numpy pytest hypothesis blas=*=openblas openblas=0.3.9 -y
conda activate cf
python -c "import numpy as np;np.test('full')"
์ถ๋ ฅ
C:\Anaconda\envs\cf\lib\site-packages\numpy\linalg\linalg.py:94: LinAlgError
---------------------------------------------------------------------- Captured stdout call ----------------------------------------------------------------------
** 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
์ด๊ฒ์ ์ด์ OpenBLAS๊ฐ ์ฌ์ฉ๋ ๋ ํ์ฌ ucrt DLL์ ๋ฒ๊ทธ ๊ธฐ๋ฅ์ด ์ฌ์ฉ๋๊ณ ์์์ ๋ณด์ฌ์ค๋๋ค.
conda forge์ openblas = 0.3.12 ๋ง ํ ์คํธ๋ฅผ ํต๊ณผํ์ง๋ง ์ด๊ฒ์ NumPy 1.19.3์์ ์ถ์ ๋ ๊ฒ๊ณผ ๋์ผํฉ๋๋ค.
๋ฌด์ฅ ํด์ ๋ OpenBLAS-0.3.12๋ก ์ปดํ์ผ ๋ ์๋ก์ด numpy ๋ฆด๋ฆฌ์ค์ ๋ํด ๋งํ๋ ๊ฒ์ ๋ฌด์์
๋๊น? numpy์ ์ฌ์ฉ๋๋ OpenBLAS์ ์ปดํ์ผ ์๊ฐ์ ๋ฒํผ ํฌ๊ธฐ๊ฐ ์ค์ด๋ค๊ณ ์ค๋ ๋ ์๊ฐ ์ค์ด๋ค ์ ์์ต๋๋ค. ์ด๋ OpenBLAS์ ๋ฉ๋ชจ๋ฆฌ ์๋น๋ฅผ ์ค์ฌ์ผํ๋ฉฐ Docker ํ
์คํธ ์ผ์ด์ค๋ฟ๋ง ์๋๋ผ ์ฅ๋น๊ฐ ๋ถ์กฑํ ์ฌ์ฉ์์๊ฒ๋ ๋์์ด ๋ ๊ฒ์
๋๋ค.
์ฐฝ ์์.
์ฌ๊ธฐ Python ๋ด๋ถ์ https://tinyurl.com/y3dm3h86 ๋ฒ๊ทธ ๋ณด๊ณ ์์์. ๋จผ์ ํ์ฌ Windows์์ ์๋ํ๋ ๋ฒ์ (1.19.3)์ ์ ๊ณตํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
1.19.3์ Linux์์ ์๋ํ์ง ์๊ณ 1.19.4๋ Windows์์ ์๋ํ์ง ์๋๋ค๋ ๊ฒ์ ์๊ณ ์์ต๋๋ค (๋ฒ๊ทธ๊ฐ์๋ ๋์).
Windows์ ๊ฒฝ์ฐ pypi 1.19.3์์ ๋ค๋ฅธ ๋ชจ๋ ํ๋ซํผ์ ๊ฒฝ์ฐ 1.19.4์์ ์ต์ ๋ฒ์ ์ ๋ง๋ค ์ ์์ต๋๊น? ์ฆ, https://files.pythonhosted.org/packages/33/26/c448c5203823d744b7e71b81c2b6dcbcd4bff972897ce989b437ee836b2b/numpy-1.19.4-cp36-cp36m-win_amd64.whl (๋ฐ ํด๋น 3.7 / 3.8 / 3.9 amd64 ๋ฒ์ )์ ์์ ํ ์ญ์ ํ๋ฉด๋ฉ๋๋ค. ์ง๊ธ์?
@luciansmith ์์ค๊ฐ 1.19.4์ ์ฌ์ฉ ๊ฐ๋ฅํ ํ pip๋ ์ถ๊ฐ ํ๋๊ทธ๊ฐ ์ ๋ฌ๋์ง ์๋ ํ์ด ๋ฒ์ ์ ์ฌ์ฉํ๋ ค๊ณ ์๋ํฉ๋๋ค. ๋๋ถ๋ถ์ ์ฌ์ฉ์๋ ๋ฌธ์ ๋ฅผ ์๊ณ ์๋ ๊ฒฝ์ฐ์๋ง ์ถ๊ฐ ํ๋๊ทธ๋ฅผ ์ ๋ฌํ ๊ฒ์ด๋ผ๊ณ ์๊ฐํ์ง๋ง 1.19.3์ ๊ณ ์ ํ ์ ์์ต๋๋ค.
๋ด ์ ํธ๋ Linux์์ OpenBLAS 0.3.9๋ฅผ ์ฌ์ฉํ๊ณ Windows์์ 0.3.12๋ฅผ ์ฌ์ฉํ๋ 1.19.5๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด์ง๋ง ์ด๊ฒ์ด ๊ฐ๋ฅํ์ง ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
OpenBLAS v0.3.12์ ๋ํ ์ ๋ฐ์ดํธ๋ฅผ ๋ณํฉํ์ผ๋ฉฐ ํด๋น ๋ฒ์ + Windows ์ ๋ฐ์ดํธ 2004๋ฅผ ์ฌ์ฉํ๋ ๋ก์ปฌ ๋น๋๊ฐ ํ ์คํธ ์ค์ํธ๋ฅผ ํต๊ณผํ์ต๋๋ค.