scikit-learn: I don't understand how to built with anaconda / MKL

When using anaconda with MKL and trying to build sklearn, I get

Intel MKL FATAL ERROR: Cannot load libmkl_avx2.so or libmkl_def.so.

Can anyone explain what is happening / how to built?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 36 (11 by maintainers)

Most upvoted comments

conda install numpy Fixed the error for me

Just for the record, browsing through your referenced comment, I found the post at Anaconda blog where they describe how to inactivate the mkl versions of the libraries (https://www.continuum.io/blog/developer-blog/anaconda-25-release-now-mkl-optimizations) and now at least I can compile a working version. Thanks!

I found that I had the same problem under numpy: 1.11.2, which could be reproduced by $ python -c 'import sklearn.linear_model.tests.test_randomized_l1' Intel MKL FATAL ERROR: Cannot load libmkl_avx.so or libmkl_def.so.

After downgrading numpy to 1.11.1 this error disappeared. conda install numpy=1.11.1 The following packages will be DOWNGRADED due to dependency conflicts: numpy: 1.11.2-py35_0 --> 1.11.1-py35_0 Proceed ([y]/n)? y

Didn’t want to disable MKL with nomkl. Adding

import mkl
mkl.get_max_threads()

Solved this problem for me.

Because of the same problem to me, I turn off mkl by conda install nomkl. I am now happy. If this problem is fixed, please share with us so that I can turn on again. Thank you for elaborating this problem.

I had the same problem, despite using the latest available packages. Turns out the solution was easier than I thought: for whatever reason Anaconda installed the MKL-enabled versions of the numpy/scipy stack, but did not actually install mkl itself. I have seen this when building Docker images based on the Jupyter minimal notebook stack.

A simple conda install --yes mkl mkl-service solved it for me.

Hi,

Just wanted to note that Anaconda 4.0.0, shipped with mkl enabled by default, has this issue. The problem is indeed with Anaconda, as it can be reproduced with the python sklearn test suggested above by @pcgreat.

The actual issue is that Anaconda linked with mkl, but not with libmkl_core.so, thus it has a missing symbol, and can be seen by running:

$ LD_DEBUG=symbols python -c 'import sklearn.linear_model.tests.test_randomized_l1' 2>&1 | grep -i error
      2200:     /opt/anaconda/lib/python2.7/site-packages/scipy/special/../../../../libmkl_avx.so: error: symbol lookup error: undefined symbol: mkl_dft_fft_fix_twiddle_table_32f (fatal)

I didn’t want to uninstall mkl, as I’d like to have the performance boost, so I found a workaround which worked for me - preload libmkl_core.so before execution.

$ python -c 'import sklearn.linear_model.tests.test_randomized_l1'
Intel MKL FATAL ERROR: Cannot load libmkl_avx.so or libmkl_def.so.
$
$ LD_PRELOAD=/opt/anaconda/lib/libmkl_core.so python -c 'import sklearn.linear_model.tests.test_randomized_l1'
$

Regards, Yanir.

it was a combination of mixing up system numpy and the LD_LIBRARY_PATH… always good fun… sorry for the noise.

conda install -c intel mkl

Worked for me

No, you are right. I should post on their issues list. It is just that I saw the error pointed here was the same and also while using anaconda, so I thought it might be related. I already asked on the pyinstaller project, because it seems to have a similar issue with other mkl libraries. In any case, I checked my numpy version in anaconda, and it is 1.10.4. Thanks anyway 😃

I am getting the same problem. @amueller Noob question: where do you search for the mixup? (ld_lib_path)