简体   繁体   English

OMP: Error #15: Initializing libiomp5.dylib, 但发现 libiomp5.dylib 已经初始化

[英]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.我正在尝试运行一个测试程序来检查我的 Anaconda 环境是否配置正确。 However, when I run my test program I get this error message when the program is setting up graph ( on_train_end() callback to be precise):但是,当我运行我的测试程序时,我在程序设置图形时收到此错误消息(准确地说是on_train_end()回调):

OMP: Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized. OMP:错误 #15:正在初始化 libiomp5.dylib,但发现 libiomp5.dylib 已经初始化。 OMP: Hint This means that multiple copies of the OpenMP runtime have been since it can degrade performance or cause incorrect results. OMP:提示这意味着 OpenMP 运行时的多个副本可能会降低性能或导致不正确的结果。 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 运行时链接到进程中,例如避免在任何库中静态链接 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/

I'm running the test program on my MacBook Pro 15" 2015 where it is installed macOS Mojave 10.14.1. The Anaconda distribution that I have currently installed is https://repo.anaconda.com/archive/Anaconda2-5.3.0-MacOSX-x86_64.sh .我正在我的 MacBook Pro 15" 2015 上运行测试程序,它安装了 macOS Mojave 10.14.1。我目前安装的 Anaconda 发行版是https://repo.anaconda.com/archive/Anaconda2-5.3.0 -MacOSX-x86_64.sh

Here is the test program:这是测试程序:

#!/usr/bin/env python

import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt

from tensorflow import keras

Xs = np.array([
    [0, 0],
    [0, 1],
    [1, 1],
    [1, 0]
])

Ys = np.array([
    [0],
    [1],
    [0],
    [1]
])

class MyCallback(keras.callbacks.Callback):
    def __init__(self):
        super(MyCallback, self).__init__()
        self.stats = []

    def on_epoch_end(self, epoch, logs=None):
        self.stats.append({
            'loss': logs['loss'],
            'acc': logs['acc'],
            'epoch': epoch
        })

    def on_train_end(self, logs=None):
        loss_x = []
        loss_y = []
        acc_x = []
        acc_y = []
        for e in self.stats:
            loss_x.append(e['epoch'])
            loss_y.append(e['loss'])
            acc_x.append(e['epoch'])
            acc_y.append(e['acc'])
        plt.plot(loss_x, loss_y, 'r', label='Loss')
        plt.plot(acc_x, acc_y, 'b', label='Accuracy')
        plt.xlabel('Epochs')
        plt.ylabel('Loss / Accuracy')
        plt.legend(loc='upper left')
        plt.show()

with tf.Session() as session:
    model = keras.models.Sequential()

    model.add(keras.layers.Dense(10, activation=keras.activations.elu, input_dim=2))
    model.add(keras.layers.Dense(1, activation=keras.activations.sigmoid))

    model.compile(optimizer=keras.optimizers.Adam(lr=0.05),
                  loss=keras.losses.mean_squared_error,
                  metrics=['accuracy'])

    model.fit(x=Xs, y=Ys, batch_size=4, epochs=50, callbacks=[MyCallback()])

    print("Training complete")

    loss, acc = model.evaluate(Xs, Ys)

    print(f"loss: {loss} - acc: {acc}")

    predictions = model.predict(Xs)

    print("predictions")
    print(predictions)

I already tried to fix the issue referencing to the answer of this related question.我已经尝试参考这个相关问题的答案来解决这个问题。 Thus, adding the following lines of code after the import section:因此,在import部分之后添加以下代码行:

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

What I get is another error message, this is the full stack trace:我得到的是另一条错误消息,这是完整的堆栈跟踪:

2018-12-06 10:18:34.262 python[19319:371282] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7ff2b07a3d00
2018-12-06 10:18:34.266 python[19319:371282] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7ff2b07a3d00'
*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff2ccf0e65 __exceptionPreprocess + 256
        1   libobjc.A.dylib                     0x00007fff58d47720 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff2cd6e22d -[NSObject(NSObject) __retain_OA] + 0
        3   CoreFoundation                      0x00007fff2cc92820 ___forwarding___ + 1486
        4   CoreFoundation                      0x00007fff2cc921c8 _CF_forwarding_prep_0 + 120
        5   libtk8.6.dylib                      0x0000000b36aeb31d TkpInit + 413
        6   libtk8.6.dylib                      0x0000000b36a4317e Initialize + 2622
        7   _tkinter.cpython-36m-darwin.so      0x0000000b3686ba16 _tkinter_create + 1174
        8   python                              0x000000010571c088 _PyCFunction_FastCallDict + 200
        9   python                              0x00000001057f2f4f call_function + 143
        10  python                              0x00000001057f0abf _PyEval_EvalFrameDefault + 46847
        11  python                              0x00000001057e4209 _PyEval_EvalCodeWithName + 425
        12  python                              0x00000001057f3b1c _PyFunction_FastCallDict + 364
        13  python                              0x000000010569a8b0 _PyObject_FastCallDict + 320
        14  python                              0x00000001056c1fe8 method_call + 136
        15  python                              0x00000001056a1efe PyObject_Call + 62
        16  python                              0x0000000105743385 slot_tp_init + 117
        17  python                              0x00000001057478c1 type_call + 241
        18  python                              0x000000010569a821 _PyObject_FastCallDict + 177
        19  python                              0x00000001056a2a67 _PyObject_FastCallKeywords + 327
        20  python                              0x00000001057f3048 call_function + 392
        21  python                              0x00000001057f0b6f _PyEval_EvalFrameDefault + 47023
        22  python                              0x00000001057f330c fast_function + 188
        23  python                              0x00000001057f2fac call_function + 236
        24  python                              0x00000001057f0abf _PyEval_EvalFrameDefault + 46847
        25  python                              0x00000001057e4209 _PyEval_EvalCodeWithName + 425
        26  python                              0x00000001057f3b1c _PyFunction_FastCallDict + 364
        27  python                              0x000000010569a8b0 _PyObject_FastCallDict + 320
        28  python                              0x00000001056c1fe8 method_call + 136
        29  python                              0x00000001056a1efe PyObject_Call + 62
        30  python                              0x00000001057f0cc0 _PyEval_EvalFrameDefault + 47360
        31  python                              0x00000001057e4209 _PyEval_EvalCodeWithName + 425
        32  python                              0x00000001057f33ba fast_function + 362
        33  python                              0x00000001057f2fac call_function + 236
        34  python                              0x00000001057f0abf _PyEval_EvalFrameDefault + 46847
        35  python                              0x00000001057f330c fast_function + 188
        36  python                              0x00000001057f2fac call_function + 236
        37  python                              0x00000001057f0abf _PyEval_EvalFrameDefault + 46847
        38  python                              0x00000001057e4209 _PyEval_EvalCodeWithName + 425
        39  python                              0x00000001057f33ba fast_function + 362
        40  python                              0x00000001057f2fac call_function + 236
        41  python                              0x00000001057f0abf _PyEval_EvalFrameDefault + 46847
        42  python                              0x00000001057e4209 _PyEval_EvalCodeWithName + 425
        43  python                              0x00000001057f33ba fast_function + 362
        44  python                              0x00000001057f2fac call_function + 236
        45  python                              0x00000001057f0b6f _PyEval_EvalFrameDefault + 47023
        46  python                              0x00000001057e4209 _PyEval_EvalCodeWithName + 425
        47  python                              0x00000001057f33ba fast_function + 362
        48  python                              0x00000001057f2fac call_function + 236
        49  python                              0x00000001057f0abf _PyEval_EvalFrameDefault + 46847
        50  python                              0x00000001057e4209 _PyEval_EvalCodeWithName + 425
        51  python                              0x00000001057f33ba fast_function + 362
        52  python                              0x00000001057f2fac call_function + 236
        53  python                              0x00000001057f0abf _PyEval_EvalFrameDefault + 46847
        54  python                              0x00000001057e4209 _PyEval_EvalCodeWithName + 425
        55  python                              0x00000001057f33ba fast_function + 362
        56  python                              0x00000001057f2fac call_function + 236
        57  python                              0x00000001057f0b6f _PyEval_EvalFrameDefault + 47023
        58  python                              0x00000001057e4209 _PyEval_EvalCodeWithName + 425
        59  python                              0x00000001057f33ba fast_function + 362
        60  python                              0x00000001057f2fac call_function + 236
        61  python                              0x00000001057f0b6f _PyEval_EvalFrameDefault + 47023
        62  python                              0x00000001057e4209 _PyEval_EvalCodeWithName + 425
        63  python                              0x000000010583cd4c PyRun_FileExFlags + 252
        64  python                              0x000000010583c224 PyRun_SimpleFileExFlags + 372
        65  python                              0x0000000105862d66 Py_Main + 3734
        66  python                              0x0000000105692929 main + 313
        67  libdyld.dylib                       0x00007fff59e1608d start + 1
        68  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Here is a list of the related dependencies installed in the environment (not related dependencies are omitted for brevity):这里列出了环境中安装的相关依赖项(不相关的依赖项为了简洁省略):

Name                |     Version                      Build
--------------------|----------------|----------------------
_tflow_select       |     2.3.0      |                   mkl
blas                |     1.0        |                   mkl
intel-openmp        |     2019.1     |                   144
matplotlib          |     3.0.1      |        py36h54f8f79_0
mkl                 |     2018.0.3   |                     1
mkl_fft             |     1.0.6      |        py36hb8a8100_0
mkl_random          |     1.0.1      |        py36h5d10147_1
numpy               |     1.15.4     |        py36h6a91979_0
numpy-base          |     1.15.4     |        py36h8a80b8c_0
tensorboard         |     1.12.0     |        py36hdc36e2c_0
tensorflow          |     1.12.0     |    mkl_py36h2b2bbaf_0
tensorflow-base     |     1.12.0     |    mkl_py36h70e0e9a_0

In most cases, this solves the problem:在大多数情况下,这可以解决问题:

conda install nomkl

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我在mac OS Mojave中使用 conda 安装的 Tensorflow 2.0 MKLpython3.6

  1. To downgrade matplotlib.降级 matplotlib。 What does it have to do something with OpenMP?它与 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.允许复制 OpenMP 库,因为它存在多个副本。 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 os os.environ['KMP_DUPLICATE_LIB_OK']='True'
  3. To install nomkl .安装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?我想这是为了不对所有库(scipy、numpy、tensorflow 等)使用基于 MKL 的二进制文件,但后来我不明白为什么要使用 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).因为重点是使用 MKL 二进制文件来利用英特尔架构进行快速处理(AVX2 指令等)。 Most of the people said this worked out for them, however, this did not work out for me:大多数人都说这对他们有用,但是,这对我来说却行不通:

     conda install nomkl
  4. Update MKL .更新MKL It did not work out.它没有成功。

     conda install -c intel mkl
  5. Uninstall OpenMP and install it again.卸载OpenMP并重新安装。 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.最后,我所做的是卸载 conda 安装的 tensorflow (tf-mkl) 并通过 pip 重新安装。 This has worked out .,.这已经解决了.,. I think this is a proper solution, So.我认为这是一个合适的解决方案,所以。 it might mean Intel TF-MKL binaries are broken for macOS.这可能意味着 Intel TF-MKL 二进制文件在 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.我观察到这对于 Intel 和 macOS 很常见,因为 OpenVINO、pyrealsense2 等其他库在 macOS 中也不能正常工作。

     conda uninstall tensorflow pip install tensorflow==2.0.0

Some useful links:一些有用的链接:

  1. https://github.com/dmlc/xgboost/issues/1715 https://github.com/dmlc/xgboost/issues/1715
  2. https://github.com/openai/spinningup/issues/16 https://github.com/openai/spinningup/issues/16
  3. Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized 错误 #15:正在初始化 libiomp5.dylib,但发现 libiomp5.dylib 已经初始化

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, ie conda install matplotlib=2.2.3最终我通过降级我的 matplotlib 版本解除了封锁,即conda install matplotlib=2.2.3

i keep running into this error and it seems to have to do with dependency based installation and conda missing symlinks after that.我一直遇到这个错误,它似乎与基于依赖的安装有关,之后 conda 缺少符号链接。

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.示例:我在我的 conda 环境中安装了一个带有 pip 的包,它具有 torch 依赖性,并且它确实安装成功 - 但是在导入时我得到了上面的错误。 The lib/ looked the following way: lib/看起来像以下方式:

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

I then used conda install pytorch which did install additional packages.然后我使用conda install pytorch确实安装了额外的包。 After that my lib/ looked like this:之后我的lib/看起来像这样:

 ~/opt/anaconda3/lib  ll|grep libomp
lrwxr-xr-x    1 user  staff    12B Dec 31 12:17 libgomp.1.dylib -> libomp.dylib
lrwxr-xr-x    1 user  staff    12B Dec 31 12:17 libgomp.dylib -> libomp.dylib
lrwxr-xr-x    1 user  staff    12B Mar 10 14:59 libiomp5.dylib -> libomp.dylib
-rwxrwxr-x    2 user  staff   646K Jan 15 22:21 libomp.dylib 

Hence the libomp.dylib and libiomp5.dylib symlink got updated.因此libomp.dyliblibiomp5.dylib符号链接得到了更新。 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!我之前还通过在这些库之间手动创建符号链接来解决此问题...因此请检查这对您是否有效!

暂无
暂无

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

相关问题 错误 #15:正在初始化 libiomp5.dylib,但发现 libiomp5.dylib 已经初始化 - 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