The Python Oracle

Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized

This video explains
Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized

--

Become part of the top 3% of the developers by applying to Toptal
https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Meadow

--

Chapters
00:00 Question
01:19 Accepted answer (Score 89)
01:42 Answer 2 (Score 66)
02:15 Answer 3 (Score 50)
03:46 Answer 4 (Score 9)
04:06 Thank you

--

Full question
https://stackoverflow.com/questions/5301...

Question links:
[http://www.intel.com/software/products/s.../]: http://www.intel.com/software/products/s.../

Accepted answer links:
[https://github.com/dmlc/xgboost/issues/1...]: https://github.com/dmlc/xgboost/issues/1...

Answer 2 links:
[https://github.com/dmlc/xgboost/issues/1...]: https://github.com/dmlc/xgboost/issues/1...

Answer 3 links:
[docs]: https://docs.anaconda.com/mkl-optimizati.../
[conda MKL Optimizations]: https://docs.anaconda.com/mkl-optimizati.../

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #macos #matplotlib



ACCEPTED ANSWER

Score 105


Do the following to solve the issue:

import os

os.environ['KMP_DUPLICATE_LIB_OK']='True'

Answer found at: https://github.com/dmlc/xgboost/issues/1715

Be aware of potential side-effects:

but that may cause crashes or silently produce incorrect results.




ANSWER 2

Score 80


This is a better solution, if applicable. Else, anyway gcamargo’s solution is likely to work. However, it comes with a warning "that it may cause crashes or silently produce incorrect results"

I had the same error on my Mac with a python program using numpy, keras, and matplotlib. I solved it with

conda install nomkl

Answer found at: https://github.com/dmlc/xgboost/issues/1715




ANSWER 3

Score 72


I had the same issue on macOS and found the following reasons:

Problem:

I had a conda environment where Numpy, SciPy and TensorFlow were installed.

Conda is using Intel(R) MKL Optimizations, see docs:

Anaconda has packaged MKL-powered binary versions of some of the most popular numerical/scientific Python libraries into MKL Optimizations for improved performance.

The Intel MKL functions (e.g. FFT, LAPACK, BLAS) are threaded with the OpenMP technology.

But on macOS you do not need MKL, because the Accelerate Framework comes with its own optimization algorithms and already uses OpenMP. That is the reason for the error message: OMP Error #15: ...

Workaround:

You should install all packages without MKL support:

conda install nomkl

and then use

conda install numpy scipy pandas tensorflow

followed by

conda remove mkl mkl-service

For more information see conda MKL Optimizations.




ANSWER 4

Score 12


I had the same issue in a conda environment where TensorFlow was installed. After doing

  • pip uninstall tensorflow
  • pip install tensorflow

the problem was gone.