简体   繁体   English

错误 #15:正在初始化 libiomp5.dylib,但发现 libiomp5.dylib 已经初始化

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

Getting the error message when using matplotlib:使用 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.错误 #15:正在初始化 libiomp5.dylib,但发现 libiomp5.dylib 已初始化 OMP: 提示:这意味着 OpenMP 运行时的多个副本已链接到程序中。 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, eg by avoiding static linking of the OpenMP runtime in any library.最好的办法是确保只有一个 OpenMP 运行时链接到进程中,例如通过避免 static 链接任何库中的 OpenMP 运行时。 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.作为一种不安全、不受支持、未记录的解决方法,您可以设置环境变量 KMP_DUPLICATE_LIB_OK=TRUE 以允许程序继续执行,但这可能会导致崩溃或默默地产生不正确的结果。 For more information, please see http://www.intel.com/software/products/support/ .有关详细信息,请参阅http://www.intel.com/software/products/support/

This seems to be a MacOS problem.这似乎是一个 MacOS 问题。 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答案在: https : //github.com/dmlc/xgboost/issues/1715

Be aware of potential side-effects:注意潜在的副作用:

"but that may cause crashes or silently produce incorrect results."

This is a better solution, if applicable.如果适用,这是一个更好的解决方案。 Else, anyway gcamargo's solution is likely to work.否则,无论如何 gcamargo 的解决方案可能会奏效。 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.我在使用 numpy、keras 和 matplotlib 的 python 程序的 Mac 上遇到了同样的错误。 I solved it with我解决了

conda install nomkl

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

I had the same issue on macOS and found the following reasons:我在 macOS 上遇到了同样的问题,并发现以下原因:

Problem:问题:

I had a conda environment where Numpy, SciPy and TensorFlow were installed.我有一个安装了 Numpy、SciPy 和 TensorFlow 的 conda 环境。

Conda is using Intel(R) MKL Optimizations, see docs : Conda 正在使用 Intel(R) MKL 优化,请参阅文档

Anaconda has packaged MKL-powered binary versions of some of the most popular numerical/scientific Python libraries into MKL Optimizations for improved performance. Anaconda 已将一些最流行的数值/科学 Python 库的 MKL 驱动的二进制版本打包到 MKL 优化中,以提高性能。

The Intel MKL functions (eg FFT, LAPACK, BLAS) are threaded with the OpenMP technology.英特尔 MKL 函数(例如 FFT、LAPACK、BLAS)采用 OpenMP 技术进行线程化。

But on macOS you do not need MKL, because the Accelerate Framework comes with its own optimization algorithms and already uses OpenMP.但是在 macOS 上你不需要 MKL,因为 Accelerate Framework 自带优化算法并且已经使用 OpenMP。 That is the reason for the error message: OMP Error #15: ...这就是错误消息的原因: OMP Error #15: ...

Workaround :解决方法

You should install all packages without MKL support:您应该安装所有没有 MKL 支持的软件包:

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 .有关更多信息,请参阅conda MKL 优化

I had the same issue in a conda environment where TensorFlow was installed.我在安装了 TensorFlow 的 conda 环境中遇到了同样的问题。 After doing做完之后

  • pip uninstall tensorflow
  • pip install tensorflow

the problem was gone.问题就解决了。

Had same issue in OSX when updating tensoflow to 1.13 using conda.使用 conda 将 tensoflow 更新到 1.13 时,在 OSX 中遇到了同样的问题。

  • Solution 1: /gcamargo worked but 3x slower per training epoch.解决方案 1:/gcamargo 可以工作,但每个训练周期慢 3 倍。
  • Solution 2: /sjcoding worked and removed serious warining but also 3x slower in training.解决方案 2:/sjcoding 工作并消除了严重警告,但训练速度也慢了 3 倍。
  • Solution 3: that restored performance was: Install pip in new conda env and use pip to install tensorflow.解决方案 3:恢复的性能是:在新的 conda env 中安装 pip 并使用 pip 安装 tensorflow。 Using conda-forge also worked but version of tf is old.使用 conda-forge 也可以,但 tf 的版本很旧。

Apparently the new Intel-MKL optimizations in Anaconda are broken for OSX tensorflow.显然,Anaconda 中新的 Intel-MKL 优化在 OSX tensorflow 中被破坏了。

Check if there's an update for the mkl package in your env (anaconda).检查您的 env (anaconda) 中的 mkl 包是否有更新。

I was able to solve my case simply by updating mkl.我能够通过更新 mkl 来解决我的问题。

conda install -c intel mkl

(macOS Catalina 10.15.5) (macOS Catalina 10.15.5)

So, for those of you getting this same issue with lightgbm, I found in the documentation that you can因此,对于那些在使用 lightgbm 时遇到同样问题的人,我在文档中发现您可以

  1. pip uninstall lightgbm
  2. pip install lightgbm
  3. Run the following in anaconda environmnet (if you're running Conda)在 anaconda 环境中运行以下命令(如果您正在运行 Conda)
ln -sf `ls -d "$(brew --cellar libomp)"/*/lib`/* $CONDA_PREFIX/lib

These three things worked for me.这三件事对我有用。

Try to change the backend of matplotlib .尝试更改matplotlib的后端。

For example, Tkagg backend causes this problem in my case.例如,在我的情况下, Tkagg后端会导致此问题。 I changed it to Qt5Agg我把它改成了Qt5Agg

matplotlib.use('Qt5Agg') 

and it helps.它有帮助。

Confronted with the same error #15, none of the solutions to-date (5 Feb 2021) fully worked despite being helpful.面对相同的错误 #15,尽管有帮助,但迄今为止(2021 年 2 月 5 日)没有一个解决方案完全有效。 However, I did manage to solve it while avoiding: dithering with dylib libraries, installing from source, or setting the environment variable KMP_DUPLICATE_LIB_OK=TRUE and its downsides of being an “unsafe, unsupported, undocumented workaround” and its potential “crashes or silently produce incorrect results”.但是,我确实设法解决了它,同时避免了:使用dylib库抖动、从源代码安装或设置环境变量KMP_DUPLICATE_LIB_OK=TRUE及其作为“不安全、不受支持、未记录的解决方法”的缺点及其潜在的“崩溃或静默产生结果不正确”。

The trouble was that conda wasn't picking up the non-mkl builds of tensorflow (v2.0.0) despite loading the nomkl package.问题是,尽管加载了nomkl包,但 conda 并没有选择 tensorflow (v2.0.0) 的非 mkl 构建。 What finally made this solution work was to:最终使该解决方案起作用的是:

  • ensure I was loading packages from the defaults channel (ie. from a channel with a non-mkl version of tensorflow. As of 5 Feb 2021, conda-forge does not have a tensorflow version of 2.0 or greater).确保我从defaults通道加载包(即从具有非 mkl 版本的 tensorflow 的通道。截至 2021 年 2 月 5 日,conda-forge 没有 2.0 或更高版本的 tensorflow 版本)。
  • specify the precise build of the tensorflow version I wanted: tensorflow>=2.*=eigen_py37h153756e_0 .指定我想要的 tensorflow 版本的精确构建: tensorflow>=2.*=eigen_py37h153756e_0 Without this, conda kept loading the mkl_... version of the package despite the nomkl package also being loaded.如果没有这个,conda 会继续加载包的mkl_...版本,尽管也加载了nomkl包。

I created a conda environment using the following environment.yml file (as per the conda documentation for managing environments ) :我使用以下 environment.yml 文件创建了一个 conda 环境(根据管理环境conda 文档):

name: tf_nomkl
channels:
  - conda-forge
  - defaults
dependencies:
  - nomkl
  - python>=3.7
  - numpy
  - scipy
  - pandas
  - jupyter
  - jupyterlab
  - nb_conda
  - nb_conda_kernels
  - ipykernel
  - pathlib
  - matplotlib
  - seaborn
  - tensorflow>=2.*=eigen_py37h153756e_0

You could try to do the same without an environment.yml file, but it's better to load all the packages you want in an environment in one go if you can.您可以尝试在没有 environment.yml 文件的情况下执行相同操作,但如果可以,最好一次性在环境中加载您想要的所有包。 This solution works on MacOS Big Sur v11.1.此解决方案适用于 MacOS Big Sur v11.1。

conda install --revision 0 doesn't solve UnsatisfiableError: The following specifications... for me. conda install --revision 0不能解决UnsatisfiableError: The following specifications...对我来说。 So I manually install nomkl and remove mkl and mil-service in Anaconda-Navigator environment, and it works great for me!所以我在 Anaconda-Navigator 环境中手动安装了nomkl并删除了mklmil-service ,它对我来说非常mkl

I was getting the same error as mentioned in the original question when I ran a code with Tensorflow on my macOS Monterey.当我在我的 macOS Monterey 上使用 Tensorflow 运行代码时,我遇到了与原始问题中提到的相同的错误。 I tried installing nomkl and removing mkl as suggested in many of the previous answers.我尝试按照以前的许多答案中的建议安装 nomkl 并删除 mkl 。 However this gave me trouble on running readcsv module of pandas and many other modules from different packages.然而,这给我运行 pandas 的 readcsv 模块和来自不同包的许多其他模块带来了麻烦。 A friend told me that newer versions of macOS have trouble with the usual Tensorflow and therefore pypi has launched a special version of TF called tf-nightly.一位朋友告诉我,新版本的 macOS 与通常的 Tensorflow 有问题,因此 pypi 推出了一个名为 tf-nightly 的特殊版本的 TF。

https://pypi.org/project/tf-nightly/#description https://pypi.org/project/tf-nightly/#description

This installation solved the problem for me.这个安装解决了我的问题。

I had the same problem.我有同样的问题。 Nothing you suggested solved the issue.你提出的任何建议都没有解决这个问题。 I found that a possible cause is that you have multiple OpenMP libraries installed on your machine and they conflict with each other.我发现一个可能的原因是您的机器上安装了多个 OpenMP 库并且它们相互冲突。 Plus, I found that the problem was numpy and I did the upgrade (conda update numpy) and FINALLY IT WORKED!!!另外,我发现问题是 numpy 并且我进行了升级(conda update numpy),终于成功了!!!

I am using Macbook M1 and I faced the same issue.我正在使用 Macbook M1,我遇到了同样的问题。 I solved this problem after removing the mkl package from my conda environment using the following command:使用以下命令从我的conda环境中删除 mkl package 后,我解决了这个问题:

conda remove mkl

This issue happens because mkl is developed for Intel users and many of my packages were comming from mkl .发生此问题是因为mkl是为英特尔用户开发的,并且我的许多软件包来自mkl After you remove this package, you will be required to reinstall many packages that you use through mkl .删除此 package 后,您将需要重新安装许多通过mkl使用的软件包。 Also, in my case, when I tried to install pandas afterwards, there was a dependency issue.此外,就我而言,当我之后尝试安装 pandas 时,存在依赖性问题。 I solved this issue as well after updating all conda packages using the following command:在使用以下命令更新所有 conda 包后,我也解决了这个问题:

conda update --all

A useful link that helped me figure this out:一个有用的链接帮助我解决了这个问题:

For me, this problem came up when I imported pytorch after numpy.对我来说,当我在 numpy 之后导入 pytorch 时出现了这个问题。 Importing them in this order fixed my problem:按此顺序导入它们解决了我的问题:

import torch
import numpy as np

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OMP: Error #15: Initializing libiomp5.dylib, 但发现 libiomp5.dylib 已经初始化 - OMP: Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized 如何修复“OMP:错误 #15:初始化 libiomp5.dylib,但发现 libomp.dylib 已初始化”错误? - How can I fix an "OMP: Error #15: Initializing libiomp5.dylib, but found libomp.dylib already initialized" error? 使用 Conda 和 matplotlib 的英特尔 MKL 错误:macOS 上的“库未加载:@rpath/libiomp5.dylib” - Intel MKL error using Conda and matplotlib: "Library not loaded: @rpath/libiomp5.dylib" on macOS 错误 #15:正在初始化 libiomp5md.dll,但发现 libiomp5md.dll 已经初始化 - Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized sklearn OMP:错误#15(“初始化 libiomp5md.dll,但发现 mk2iomp5md.dll 已经初始化。”)在拟合模型时 - sklearn OMP: Error #15 ("Initializing libiomp5md.dll, but found mk2iomp5md.dll already initialized.") when fitting models 找不到所需的dylib'libmysqlclient.18.dylib' - required dylib 'libmysqlclient.18.dylib' not found Python pygame 错误:加载 libpng.dylib 失败:dlopen(libpng.dylib, 2):找不到图像 - Python pygame error : Failed loading libpng.dylib: dlopen(libpng.dylib, 2): image not found 使用py2exe在Python中打包软件,找不到“libiomp5md.dll” - pack a software in Python using py2exe with 'libiomp5md.dll' not found Matplotlib 错误:libfreetype.6.dylib - Matplotlib error: libfreetype.6.dylib Python:找不到 libpython3.5.dylib? - Python: libpython3.5.dylib not found?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM