Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Getting the error message when using matplotlib:

Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized OMP: Hint: This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/.

like image 267
gcamargo Avatar asked Oct 26 '18 18:10

gcamargo


People also ask

What do you mean by the error?

An error is something you have done which is considered to be incorrect or wrong, or which should not have been done. NASA discovered a mathematical error in its calculations. [ + in]

What is error and examples?

The definition of an error is a mistake or the state of being wrong. An example of an error is when you add 2+2 and get 5. An example of error is when a mistake leads you to come to the wrong collusion and you continue to believe this incorrect conclusion.

What is mean by no error?

No Error. Explanation: This is a grammatically correct sentence that needs no stylistic improvements.

What is the verb of error?

verb. \ ˈer , ˈər \ erred; erring; errs.


3 Answers

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.

like image 160
gcamargo Avatar answered Sep 28 '22 22:09

gcamargo


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

like image 21
sjcoding Avatar answered Sep 28 '22 21:09

sjcoding


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.

like image 27
J.E.K Avatar answered Sep 28 '22 22:09

J.E.K