Skip to content Skip to sidebar Skip to footer

Omp: Error #15: Initializing Libiomp5.dylib, But Found Libiomp5.dylib Already Initialized

I'm trying to run a test program to check if my Anaconda environment is configured correctly. However, when I run my test program I get this error message when the program is setti

Solution 1:

In most cases, this solves the problem:

conda install nomkl

Solution 2:

I have tried the following solutions that I have come across. Unfortunately, many of them did not work out and the reasons behind them are also not very clear:

I was using conda installed Tensorflow 2.0 MKL with python3.6 in mac OS Mojave

  1. To downgrade matplotlib. What does it have to do something with OpenMP? Reason not clear but it did not work out.

    conda install matplotlib==2.2.3 
    
  2. Allow duplication of OpenMP library because of multiple copies of it exist. This works out but in the warning log, it says this is a workaround and silently produce incorrect results. So, definitely, this is not the way to go, therefore still a proper solution/fix is required.

    import osos.environ['KMP_DUPLICATE_LIB_OK']='True'
  3. To install nomkl. I guess this is to not use MKL based binaries for all the libraries (scipy, numpy, tensorflow etc) but then I do not get the point why to use Tensorflow-MKL? because the whole point is to use MKL binaries to take advantage of the Intel architecture to do fast processing (AVX2 instructions etc). Most of the people said this worked out for them, however, this did not work out for me:

    conda install nomkl
    
  4. Update MKL. It did not work out.

    conda install -c intel mkl
    
  5. Uninstall OpenMP and install it again. It did not work out.

    conda uninstall openmp
    conda install openmp
    
  6. Finally, what I did is to uninstall conda installed tensorflow (tf-mkl) and install it again via pip. This has worked out!!! I think this is a proper solution. So, it might mean Intel TF-MKL binaries are broken for macOS. I have an observation this is common for Intel and macOS since other libraries like OpenVINO, pyrealsense2 etc are also not working well in macOS.

    conda uninstall tensorflow
    pip install tensorflow==2.0.0 
    

Some useful links:

  1. https://github.com/dmlc/xgboost/issues/1715
  2. https://github.com/openai/spinningup/issues/16
  3. Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized

Solution 3:

I had a similar experience and solutions posted elsewhere were not fixing things for me. Eventually I got unblocked by downgrading my version of matplotlib, i.e. conda install matplotlib=2.2.3

Solution 4:

i keep running into this error and it seems to have to do with dependency based installation and conda missing symlinks after that.

Example: I installed a package with pip in my conda environment which had a torch dependency, and it did install successfully - but when importing i got the error above. The lib/ looked the following way:

~/opt/anaconda3/lib  ll|grep libomp
lrwxr-xr-x    1user  staff    12B Dec3112:17 libgomp.1.dylib -> libomp.dylib
lrwxr-xr-x    1user  staff    12B Dec3112:17 libgomp.dylib -> libomp.dylib
lrwxr-xr-x    1user  staff    12B Dec3112:17 libiomp5.dylib -> libomp.dylib
-rwxrwxr-x    1 iser  staff   642K Dec3112:17 libomp.dylib 

I then used conda install pytorch which did install additional packages. After that my lib/looked like this:

~/opt/anaconda3/lib  ll|grep libomp
lrwxr-xr-x    1user  staff    12B Dec3112:17 libgomp.1.dylib -> libomp.dylib
lrwxr-xr-x    1user  staff    12B Dec3112:17 libgomp.dylib -> libomp.dylib
lrwxr-xr-x    1user  staff    12B Mar 1014:59 libiomp5.dylib -> libomp.dylib
-rwxrwxr-x    2user  staff   646K Jan 1522:21 libomp.dylib 

Hence the libomp.dylib and libiomp5.dylib symlink got updated. Import worked then.

I also fixed this issue before by manually creating a symlink between those libraries... so check if this looks valid for you!

Post a Comment for "Omp: Error #15: Initializing Libiomp5.dylib, But Found Libiomp5.dylib Already Initialized"