8000 Problems with Intel MKL · Issue #6669 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Problems with Intel MKL #6669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rmalouf opened this issue Nov 12, 2015 · 24 comments
Closed

Problems with Intel MKL #6669

rmalouf opened this issue Nov 12, 2015 · 24 comments

Comments

@rmalouf
Copy link
Contributor
rmalouf commented Nov 12, 2015

I've been trying to get numpy working with Intel's MKL math library without much success.

The first problem was convincing numpy's build process to use MKL even though I have openblas installed on my system The problem is in distutils/system_info.py checks for the existence of openblas before checking whether MKL is configured. Checking MKL first resolved that issue (I can submit a patch if you're interested).

That leads to the second problem. When linked with MKL, numpy fails several of it's tests. Specifically:

======================================================================
ERROR: test_umath.TestComplexFunctions.test_loss_of_precision(<class 'numpy.complex64'>,)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/malouf/python/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1634, in check_loss_of_precision
    check(x_series, 2.1*eps)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1603, in check
    d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
RuntimeWarning: divide by zero encountered in true_divide

======================================================================
ERROR: test_umath.TestComplexFunctions.test_loss_of_precision(<class 'numpy.complex128'>,)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/malouf/python/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1634, in check_loss_of_precision
    check(x_series, 2.1*eps)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1603, in check
    d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
RuntimeWarning: divide by zero encountered in true_divide

======================================================================
ERROR: test_umath.TestComplexFunctions.test_loss_of_precision_longcomplex
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/malouf/python/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/decorators.py", line 216, in knownfailer
    return f(*args, **kwargs)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1681, in test_loss_of_precision_longcomplex
    self.check_loss_of_precision(np.longcomplex)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1632, in check_loss_of_precision
    check(x_series, 50*eps)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1603, in check
    d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
RuntimeWarning: divide by zero encountered in true_divide

======================================================================
ERROR: test_scripts.test_f2py
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/malouf/python/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/decorators.py", line 146, in skipper_func
    return f(*args, **kwargs)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/tests/test_scripts.py", line 68, in test_f2py
    code, stdout, stderr = run_command([f2py_cmd, '-v'])
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/tests/test_scripts.py", line 48, in run_command
    proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
  File "/home/malouf/python/lib/python3.5/subprocess.py", line 950, in __init__
    restore_signals, start_new_session)
  File "/home/malouf/python/lib/python3.5/subprocess.py", line 1540, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'f2py3.5'

======================================================================
FAIL: test_accelerate_framework_sgemv_fix (test_multiarray.TestDot)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_multiarray.py", line 4275, in test_accelerate_framework_sgemv_fix
    assert_dot_close(A_f, X_f, desired)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_multiarray.py", line 4260, in assert_dot_close
    assert_allclose(np.dot(A, X), desired, rtol=1e-5, atol=1e-7)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 1347, in assert_allclose
    verbose=verbose, header=header)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 708, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Not equal to tolerance rtol=1e-05, atol=1e-07

(mismatch 62.68%)
 x: array([ 163.433014,  144.792694,  145.528854, ...,  103.144707,
         94.63633 ,   98.819527], dtype=float32)
 y: array([  54.477672,   48.264233,   48.50962 , ...,  103.144708,
         94.636337,  148.229279])

======================================================================
FAIL: test_dot_3args (test_multiarray.TestDot)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_multiarray.py", line 4171, in test_dot_3args
    assert_array_equal(r2, r)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 782, in assert_array_equal
    verbose=verbose, header='Arrays are not equal')
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 708, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not equal

(mismatch 39.74609375%)
 x: array([  7.675112,  11.017172,   5.982513, ...,  14.025107,  14.226657,
        20.369611])
 y: array([ 11.512668,  16.525758,   8.973769, ...,  14.025107,  14.226657,
        20.369611])

======================================================================
FAIL: test_polyfit_build (test_regression.TestRegression)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/lib/tests/test_regression.py", line 111, in test_polyfit_build
    assert_array_almost_equal(ref, tested)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 886, in assert_array_almost_equal
    precision=decimal)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 708, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not almost equal to 6 decimals

(mismatch 100.0%)
 x: array([ -1.061238e-06,   5.708869e-04,  -1.138220e-01,   9.953682e+00,
        -3.145265e+02])
 y: array([ 0.003459, -0.012066,  0.046189, -0.349192,  0.086812])

I don't even know where to begin to isolate the problem. Has anyone reported this before? What other information would be helpful? I'm using numpy 1.10.1, python 3.5.0, gcc 4.8.3, MKL 11.3.

@charris
Copy link
Member
charris commented Nov 12, 2015

RuntimeWarning is an error because of a bug in the 1.10.1 release, you can ignore those. Some of the others may be fixed in 1.10.2 when it comes out. The 'f2py3.5' thing is strange.

@rmalouf
Copy link
Contributor Author
rmalouf commented Nov 12, 2015

It's the failed tests that I'm worried about. Note that numpy+openblas in the same environment passes those tests. And, what got me looking at this is that one of my programs gave me good results on an AMD machine using numpy+openblas but terrible results on an Intel machine using numpy+MKL.

@njsmith
Copy link
Member
njsmith commented Nov 12, 2015

We (= the numpy core team) don't really test numpy against MKL ourselves...
I don't think any of us use it personally, and mostly downstream
distributors who use MKL like Continuum seem to apply some local hacks that
they may or may not get around to sharing back upstream.
.
I know Intel is very interested in making MKL easy to use with numpy,
though, so I'm CC'ing some folks there on this to see if they have any
suggestions for what we should do with bugs like this (other than, express
sympathy and hope the original reporter is inspired to debug and fix things
themselves and submit a patch :-)). For other areas in numpy that require
special knowledge (e.g. f2py, or details of SIMD core loops) then we tend
to have a short list of people who we know are knowledgeable and care about
this area and when a bug comes in we @-mention their github username to
bring the bug to their attention. At the moment I don't know of anyone like
that for MKL-in-numpy, though.

On Wed, Nov 11, 2015 at 4:16 PM, Rob Malouf notifications@github.com
wrote:

I've been trying to get numpy working with Intel's MKL math library
without much success.

The first problem was convincing numpy's build process to use MKL even
though I have openblas installed on my system The problem is in
distutils/system_info.py checks for the existence of openblas before
checking whether MKL is configured. Checking MKL first resolved that issue
(I can submit a patch if you're interested).

That leads to the second problem. When linked with MKL, numpy fails
several of it's tests. Specifically:

ERROR: test_umath.TestComplexFunctions.test_loss_of_precision(<class 'numpy.complex64'>,)

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
self.test(_self.arg)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1634, in check_loss_of_precision
check(x_series, 2.1_eps)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1603, in check
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
RuntimeWarning: divide by zero encountered in true_divide

ERROR: test_umath.TestComplexFunctions.test_loss_of_precision(<class 'numpy.complex128'>,)

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
self.test(_self.arg)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1634, in check_loss_of_precision
check(x_series, 2.1_eps)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1603, in check
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
RuntimeWarning: divide by zero encountered in true_divide

ERROR: test_umath.TestComplexFunctions.test_loss_of_precision_longcomplex

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
self.test(_self.arg)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/decorators.py", line 216, in knownfailer
return f(_args, *_kwargs)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1681, in test_loss_of_precision_longcomplex
self.check_loss_of_precision(np.longcomplex)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1632, in check_loss_of_precision
check(x_series, 50_eps)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1603, in check
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
RuntimeWarning: divide by zero encountered in true_divide

ERROR: test_scripts.test_f2py

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
self.test(_self.arg)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/decorators.py", line 146, in skipper_func
return f(_args, **kwargs)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/tests/test_scripts.py", line 68, in test_f2py
code, stdout, stderr = run_command([f2py_cmd, '-v'])
File "/home/malouf/python/lib/python3.5/site-packages/numpy/tests/test_scripts.py", line 48, in run_command
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
File "/home/malouf/python/lib/python3.5/subprocess.py", line 950, in init
restore_signals, start_new_session)
File "/home/malouf/python/lib/python3.5/subprocess.py", line 1540, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'f2py3.5'

FAIL: test_accelerate_framework_sgemv_fix (test_multiarray.TestDot)

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_multiarray.py", line 4275, in test_accelerate_framework_sgemv_fix
assert_dot_close(A_f, X_f, desired)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_multiarray.py", line 4260, in assert_dot_close
assert_allclose(np.dot(A, X), desired, rtol=1e-5, atol=1e-7)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 1347, in assert_allclose
verbose=verbose, header=header)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 708, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Not equal to tolerance rtol=1e-05, atol=1e-07

(mismatch 62.68%)
x: array([ 163.433014, 144.792694, 145.528854, ..., 103.144707,
94.63633 , 98.819527], dtype=float32)
y: array([ 54.477672, 48.264233, 48.50962 , ..., 103.144708,
94.636337, 148.229279])

FAIL: test_dot_3args (test_multiarray.TestDot)

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_multiarray.py", line 4171, in test_dot_3args
assert_array_equal(r2, r)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 782, in assert_array_equal
verbose=verbose, header='Arrays are not equal')
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 708, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not equal

(mismatch 39.74609375%)
x: array([ 7.675112, 11.017172, 5.982513, ..., 14.025107, 14.226657,
20.369611])
y: array([ 11.512668, 16.525758, 8.973769, ..., 14.025107, 14.226657,
20.369611])

FAIL: test_polyfit_build (test_regression.TestRegression)

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/numpy/lib/tests/test_regression.py", line 111, in test_polyfit_build
assert_array_almost_equal(ref, tested)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 886, in assert_array_almost_equal
precision=decimal)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 708, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not almost equal to 6 decimals

(mismatch 100.0%)
x: array([ -1.061238e-06, 5.708869e-04, -1.138220e-01, 9.953682e+00,
-3.145265e+02])
y: array([ 0.003459, -0.012066, 0.046189, -0.349192, 0.086812])

I don't even know where to begin to isolate the problem. Has anyone
reported this before? What other information would be helpful? I'm using
numpy 1.10.1, python 3.5.0, gcc 4.8.3, MKL 11.3.


Reply to this email directly or view it on GitHub
#6669.

Nathaniel J. Smith -- http://vorpus.org

@njsmith
Copy link
Member
njsmith commented Nov 12, 2015

(And for clarity, note that by "CC" I mean "on my email reply to github,
only". They haven't been added to the actual issue CC list, so they won't
see any replies you post unless they happen to come look at the bug.
Because I don't know how to add them, which is the problem ;-).)

On Thu, Nov 12, 2015 at 3:12 PM, Nathaniel Smith njs@pobox.com wrote:

We (= the numpy core team) don't really test numpy against MKL
ourselves... I don't think any of us use it personally, and mostly
downstream distributors who use MKL like Continuum seem to apply some local
hacks that they may or may not get around to sharing back upstream.
.
I know Intel is very interested in making MKL easy to use with numpy,
though, so I'm CC'ing some folks there on this to see if they have any
suggestions for what we should do with bugs like this (other than, express
sympathy and hope the original reporter is inspired to debug and fix things
themselves and submit a patch :-)). For other areas in numpy that require
special knowledge (e.g. f2py, or details of SIMD core loops) then we tend
to have a short list of people who we know are knowledgeable and care about
this area and when a bug comes in we @-mention their github username to
bring the bug to their attention. At the moment I don't know of anyone like
that for MKL-in-numpy, though.

On Wed, Nov 11, 2015 at 4:16 PM, Rob Malouf notifications@github.com
wrote:

I've been trying to get numpy working with Intel's MKL math library
without much success.

The first problem was convincing numpy's build process to use MKL even
though I have openblas installed on my system The problem is in
distutils/system_info.py checks for the existence of openblas before
checking whether MKL is configured. Checking MKL first resolved that issue
(I can submit a patch if you're interested).

That leads to the second problem. When linked with MKL, numpy fails
several of it's tests. Specifically:

ERROR: test_umath.TestComplexFunctions.test_loss_of_precision(<class 'numpy.complex64'>,)

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
self.test(_self.arg)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1634, in check_loss_of_precision
check(x_series, 2.1_eps)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1603, in check
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
RuntimeWarning: divide by zero encountered in true_divide

ERROR: test_umath.TestComplexFunctions.test_loss_of_precision(<class 'numpy.complex128'>,)

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
self.test(_self.arg)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1634, in check_loss_of_precision
check(x_series, 2.1_eps)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1603, in check
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
RuntimeWarning: divide by zero encountered in true_divide

ERROR: test_umath.TestComplexFunctions.test_loss_of_precision_longcomplex

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
self.test(_self.arg)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/decorators.py", line 216, in knownfailer
return f(_args, *_kwargs)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1681, in test_loss_of_precision_longcomplex
self.check_loss_of_precision(np.longcomplex)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1632, in check_loss_of_precision
check(x_series, 50_eps)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_umath.py", line 1603, in check
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
RuntimeWarning: divide by zero encountered in true_divide

ERROR: test_scripts.test_f2py

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
self.test(_self.arg)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/decorators.py", line 146, in skipper_func
return f(_args, **kwargs)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/tests/test_scripts.py", line 68, in test_f2py
code, stdout, stderr = run_command([f2py_cmd, '-v'])
File "/home/malouf/python/lib/python3.5/site-packages/numpy/tests/test_scripts.py", line 48, in run_command
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
File "/home/malouf/python/lib/python3.5/subprocess.py", line 950, in init
restore_signals, start_new_session)
File "/home/malouf/python/lib/python3.5/subprocess.py", line 1540, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'f2py3.5'

FAIL: test_accelerate_framework_sgemv_fix (test_multiarray.TestDot)

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_multiarray.py", line 4275, in test_accelerate_framework_sgemv_fix
assert_dot_close(A_f, X_f, desired)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_multiarray.py", line 4260, in assert_dot_close
assert_allclose(np.dot(A, X), desired, rtol=1e-5, atol=1e-7)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 1347, in assert_allclose
verbose=verbose, header=header)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 708, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Not equal to tolerance rtol=1e-05, atol=1e-07

(mismatch 62.68%)
x: array([ 163.433014, 144.792694, 145.528854, ..., 103.144707,
94.63633 , 98.819527], dtype=float32)
y: array([ 54.477672, 48.264233, 48.50962 , ..., 103.144708,
94.636337, 148.229279])

FAIL: test_dot_3args (test_multiarray.TestDot)

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_multiarray.py", line 4171, in test_dot_3args
assert_array_equal(r2, r)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 782, in assert_array_equal
verbose=verbose, header='Arrays are not equal')
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 708, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not equal

(mismatch 39.74609375%)
x: array([ 7.675112, 11.017172, 5.982513, ..., 14.025107, 14.226657,
20.369611])
y: array([ 11.512668, 16.525758, 8.973769, ..., 14.025107, 14.226657,
20.369611])

FAIL: test_polyfit_build (test_regression.TestRegression)

Traceback (most recent call last):
File "/home/malouf/python/lib/python3.5/site-packages/numpy/lib/tests/test_regression.py", line 111, in test_polyfit_build
assert_array_almost_equal(ref, tested)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 886, in assert_array_almost_equal
precision=decimal)
File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 708, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not almost equal to 6 decimals

(mismatch 100.0%)
x: array([ -1.061238e-06, 5.708869e-04, -1.138220e-01, 9.953682e+00,
-3.145265e+02])
y: array([ 0.003459, -0.012066, 0.046189, -0.349192, 0.086812])

I don't even know where to begin to isolate the problem. Has anyone
reported this before? What other information would be helpful? I'm using
numpy 1.10.1, python 3.5.0, gcc 4.8.3, MKL 11.3.


Reply to this email directly or view it on GitHub
#6669.

Nathaniel J. Smith -- http://vorpus.org

Nathaniel J. Smith -- http://vorpus.org

@rmalouf
Copy link
Contributor Author
rmalouf commented Nov 12, 2015

Okay, sounds reasonable. The fix for me is easy -- just use OpenBLAS -- but if I manage to get any more clues about what's going on with MKL I'll let you know.

@rmalouf
Copy link
Contributor Author
rmalouf commented Nov 14, 2015

Another piece of information: numpy + MKL appears to be working when using pthreads, but not with openmp. If that helps.

@charris
Copy link
Member
charris commented Nov 14, 2015

Actually, that does jiggle my memory a bit. ISTR openmp problems with the gnu compilers also, seems to be feature of the software ;) Might be worth looking into.

@njsmith
Copy link
Member
njsmith commented Nov 14, 2015

The problem with gnu OpenMP is that it isn't fork safe. Can't see how that would be relevant to those test failures. Plus Intel OpenMP is fork safe anyway, though I'm not sure what happens when you use gcc + OpenMP + mkl together.

@anton-malakhov
Copy link

for GNU OpenMP+MKL, you might want to set MKL_THREADING_LAYER=GNU env var.

@rgommers
Copy link
Member

There are 3 issues that may still exist (the rest is fixed):

FAIL: test_accelerate_framework_sgemv_fix (test_multiarray.TestDot)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_multiarray.py", line 4275, in test_accelerate_framework_sgemv_fix
    assert_dot_close(A_f, X_f, desired)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_multiarray.py", line 4260, in assert_dot_close
    assert_allclose(np.dot(A, X), desired, rtol=1e-5, atol=1e-7)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 1347, in assert_allclose
    verbose=verbose, header=header)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 708, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Not equal to tolerance rtol=1e-05, atol=1e-07

(mismatch 62.68%)
 x: array([ 163.433014,  144.792694,  145.528854, ...,  103.144707,
         94.63633 ,   98.819527], dtype=float32)
 y: array([  54.477672,   48.264233,   48.50962 , ...,  103.144708,
         94.636337,  148.229279])

======================================================================
FAIL: test_dot_3args (test_multiarray.TestDot)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/core/tests/test_multiarray.py", line 4171, in test_dot_3args
    assert_array_equal(r2, r)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 782, in assert_array_equal
    verbose=verbose, header='Arrays are not equal')
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 708, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not equal

(mismatch 39.74609375%)
 x: array([  7.675112,  11.017172,   5.982513, ...,  14.025107,  14.226657,
        20.369611])
 y: array([ 11.512668,  16.525758,   8.973769, ...,  14.025107,  14.226657,
        20.369611])

======================================================================
FAIL: test_polyfit_build (test_regression.TestRegression)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/lib/tests/test_regression.py", line 111, in test_polyfit_build
    assert_array_almost_equal(ref, tested)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 886, in assert_array_almost_equal
    precision=decimal)
  File "/home/malouf/python/lib/python3.5/site-packages/numpy/testing/utils.py", line 708, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not almost equal to 6 decimals

(mismatch 100.0%)
 x: array([ -1.061238e-06,   5.708869e-04,  -1.138220e-01,   9.953682e+00,
        -3.145265e+02])
 y: array([ 0.003459, -0.012066,  0.046189, -0.349192,  0.086812])

@anton-malakhov
Copy link

We'll take a look

@anton-malakhov
Copy link

Disclosure: I'm from Intel. So, we are not yet able to get back to those issues, but this will be our ongoing work in a few weeks.

@rgommers
Copy link
Member

Thanks @antalmal

8000
@rgommers
Copy link
Member

The first problem was convincing numpy's build process to use MKL even though I have openblas installed on my system The problem is in distutils/system_info.py checks for the existence of openblas before checking whether MKL is configured. Checking MKL first resolved that issue (I can submit a patch if you're interested).

I see that no one replied to this part yet. @rmalouf you should be able to specify that MKL is to be used in site.cfg. Doesn't that work?

@tsailiming
Copy link

Another info on this issue. This is on numpy 1.10.4 with stock python 2.7.5 on CentOS 7.

Using l_mkl_11.3.1.150. Using the following site.cfg:

[mkl]
library_dirs = /opt/intel/mkl/lib/intel64
include_dirs = /opt/intel/mkl/include
mkl_libs = mkl_rt
lapack_libs =
======================================================================
FAIL: test_umath.TestComplexFunctions.test_loss_of_precision(<type 'numpy.complex64'>,)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/numpy/core/tests/test_umath.py", line 1634, in check_loss_of_precision
    check(x_series, 2.1*eps)
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/numpy/core/tests/test_umath.py", line 1605, in check
    'arcsinh'))
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/numpy/testing/utils.py", line 53, in assert_
    raise AssertionError(smsg)
AssertionError: (0, 9.9999997e-21, inf, 'arcsinh')

======================================================================
FAIL: test_umath.TestComplexFunctions.test_loss_of_precision(<type 'numpy.complex128'>,)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/numpy/core/tests/test_umath.py", line 1634, in check_loss_of_precision
    check(x_series, 2.1*eps)
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/numpy/core/tests/test_umath.py", line 1605, in check
    'arcsinh'))
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/numpy/testing/utils.py", line 53, in assert_
    raise AssertionError(smsg)
AssertionError: (0, 9.9999999999999995e-21, inf, 'arcsinh')

======================================================================
FAIL: test_umath.TestComplexFunctions.test_loss_of_precision_longcomplex
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/numpy/testing/decorators.py", line 216, in knownfailer
    return f(*args, **kwargs)
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/numpy/core/tests/test_umath.py", line 1681, in test_loss_of_precision_longcomplex
    self.check_loss_of_precision(np.longcomplex)
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/numpy/core/tests/test_umath.py", line 1632, in check_loss_of_precision
    check(x_series, 50*eps)
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/numpy/core/tests/test_umath.py", line 1605, in check
    'arcsinh'))
  File "/home/niot-user/kien_numpy_intelmkl/lib/python2.7/site-packages/numpy/testing/utils.py", line 53, in assert_
    raise AssertionError(smsg)
AssertionError: (0, 9.9999999999999994515e-21, inf, 'arcsinh')

@johnhinrichsen
Copy link

I get the same three arcsinh assertion failures on Centos 7 with python 2.7.8 and openblas (I tried both 0.2.14 and 0.2.15.)

@charris
Copy link
Member
charris commented Feb 2, 2016

The arcsinh issues are library related, I don't know which math library mkl links to. The f2py issue might be fixed in 1.11, or might not. It would be good if you could determine where /bin/f2py is installed and if it is on the path.

@johnhinrichsen
Copy link

I got f2py working. The arcsinh asserts are still a problem.
Also, note that I am using openblas, not mkl, and I get exactly the same assertion errors as tsailiming.

@johnhinrichsen
Copy link

The arcsinh issue is specific to Centos 7: I have found that, with a little work, I can get all tests to pass with python 2.7.8 and openblas 0.2.15 on Centos 6.

While building on Centos 6, I did run into a different test failure, which I worked around using these instructions.

Centos 7 uses glibc-2.17. I wonder if these assertion failures might also be related to glibc.

@charris
Copy link
Member
charris commented Feb 2, 2016

Hmm, currently we blacklist a bunch of functions for glibc < 2.16. You can play with the blacklist in numpy/core/src/private/npy_config.h.

@johnhinrichsen
Copy link

numpy on Centos 7 (glibc == 2.17) runs the test suite successfully after building with the following appended to numpy/core/src/private/npy_config.h:

#undef HAVE_CASIN
#undef HAVE_CASINF
#undef HAVE_CASINL
#undef HAVE_CASINH
#undef HAVE_CASINHF
#undef HAVE_CASINHL
#undef HAVE_CATAN
#undef HAVE_CATANF
#undef HAVE_CATANL
#undef HAVE_CATANH
#undef HAVE_CATANHF
#undef HAVE_CATANHL

@mrslezak
Copy link

To the comment about compiling NumPy 1.10.4 with MKL 11.3.x, I've compiled it and the site.cfg is just:

[mkl]
library_dirs = /opt/intel/mkl/lib/intel64
include_dirs = /opt/intel/mkl/include
mkl_libs = mkl_lapack95_lp64, mkl_blas95_lp64, mkl_rt
lapack_libs = mkl_lapack95_lp64, mkl_blas95_lp64, mkl_rt

However note I'm compiling with Intel's compiler 2015 XE parallel studio, and Microsoft Visual Studio 2015 Community (for Python 3.5). You'll have to get it right for your Python build (MSVC compiler).

That passes all tests except 1 which looks like a bug in the test script more than anything else. Building SciPy on top of this doesn't produce any errors after sp.test()

@rmalouf
Copy link
Contributor Author
rmalouf commented Feb 11, 2016

The issue with building numpy+mkl comes up if you've also got openblas installed in a place where distutils can find it. Since it checks for openblas first, it'll use it even if you've specified mkl in site.cfg. I just submitted a PR (#7232) to correct that.

@mattip
Copy link
Member
mattip commented Jun 12, 2018

The first problem described here is the order of mkl and openblas, which was fixed. There are duplicate and ongoing issues with mkl/openblas and multithreading. Closing this in favor of the other, more updated ones

@mattip mattip closed this as completed Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants
0