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

浪子不回头ぞ 提交于 2019-11-27 21:36:08

问题


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/.


回答1:


This seems to be a MacOS problem. 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




回答2:


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




回答3:


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.




回答4:


Had same issue in OSX when updating tensoflow to 1.13 using conda.

  • Solution 1: /gcamargo worked but 3x slower per training epoch.
  • Solution 2: /sjcoding worked and removed serious warining but also 3x slower in training.
  • Solution 3: that restored performance was: Install pip in new conda env and use pip to install tensorflow. Using conda-forge also worked but version of tf is old.

Apparently the new Intel-MKL optimizations in Anaconda are broken for OSX tensorflow.




回答5:


So, for those of you getting this same issue with lightgbm, I found in the documentation that you can

  1. pip uninstall lightgbm
  2. pip install lightgbm
  3. Run the following in anaconda environmnet (if you're running Conda)
ln -sf `ls -d "$(brew --cellar libomp)"/*/lib`/* $CONDA_PREFIX/lib

These three things worked for me.




回答6:


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.




回答7:


Try to change the backend of matplotlib.

For example, Tkagg backend causes this problem in my case. I changed it to Qt5Agg

matplotlib.use('Qt5Agg') 

and it helps.



来源:https://stackoverflow.com/questions/53014306/error-15-initializing-libiomp5-dylib-but-found-libiomp5-dylib-already-initial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!