3

I get this error when I'm running Python 3.6 Jupyter notebooks in the console.

OMP: Error #15: Initializing libiomp5.dylib, but found libomp.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/.

I have a few different versions of ligomp:

(µ_env) jespinozlt-osx:lib jespinoz$ pwd
/Users/jespinoz/anaconda/envs/µ_env/lib
(µ_env) jespinozlt-osx:lib jespinoz$ ls -lhtr | grep "omp"
-rw-rw-r--    4 jespinoz  tigr   165B Oct 28  2016 libgomp.spec
-rw-rw-r--    4 jespinoz  tigr   108K Oct 28  2016 libgomp.a
-rwxrwxr-x   11 jespinoz  tigr    62K Oct 28  2016 libgomp.1.dylib
-rwxrwxr-x    6 jespinoz  tigr   489K Oct 27 17:30 libomp.dylib
-rwxrwxr-x    5 jespinoz  tigr   176K Mar 14 13:10 libiompstubs5.dylib
-rwxrwxr-x    5 jespinoz  tigr   296K Mar 14 13:10 libiomp5_db.dylib
-rwxrwxr-x    5 jespinoz  tigr   2.7M Mar 14 13:10 libiomp5.dylib
lrwxr-xr-x    1 jespinoz  tigr    15B Apr 10 14:51 libgomp.dylib -> libgomp.1.dylib

A quick patch is this:

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

How can I properly fix this? Do I need to delete my entire conda and start over?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
O.rka
  • 29,847
  • 68
  • 194
  • 309
  • Please show how you're running the Notebooks in the console. What libraries are you using that use OpenMP? How did you install those libraries? – darthbith Apr 16 '19 at 19:21
  • libiomp5 is the Intel OpenMP runtime (not the GCC one). libomp is the LLVM OpenMP runtime (which is effectively the same as the Intel one; they share the same sources). So it looks as if you're using LLVM compiled OpenMP code and code compiled by the Intel compiler (probably in different libraries). You could fix that by making one of those two libraries a symbolic link to the other, or just don't turn on the warning :-) – Jim Cownie Apr 17 '19 at 09:22
  • The error has only occurred when running `pandas` and `matplotlib` but it could be something else as well. In particular, the `pd.concat` and `plt.annotate/plt.text` functions. – O.rka Apr 17 '19 at 20:19
  • Related: [OMP: Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized](https://stackoverflow.com/q/53648730/1364007) and [Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized](https://stackoverflow.com/q/53014306/1364007) – Wai Ha Lee Sep 09 '21 at 11:43

2 Answers2

1

I had this problem and tried a number of solutions described at https://github.com/dmlc/xgboost/issues/1715.

The posting by Alex Evers (1ps0 commented on Feb 16 (2019)) worked for me.

brew uninstall libiomp clamp-omp  
conda uninstall intel-openmp -n base  
conda install -c intel openmp -n myenv  
conda install nomkl -n myenv
cenk
  • 1,389
  • 14
  • 27
-1

I found a solution from the same source https://github.com/dmlc/xgboost/issues/1715

This seems to be a problem specific to macOS.

What worked for me is adding the following lines of code in the beginning.

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

PS. I experienced this while running Keras neural net.

Amartis Glady
  • 181
  • 1
  • 2