Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
symPhysics opened this issue Oct 28, 2016 · 81 comments

Comments

@symPhysics
Copy link

For bugs or installation issues, please provide the following information.
The more information you provide, the more easily we will be able to offer
help and advice.

Environment info

Operating System: Mac OSX Sierra 10.12.1

Compiler:

Package used (python):

xgboost version used: xgboost 0.6a2

If you are using python package, please provide

  1. The python version and distribution:
    Pythong 2.7.12
  2. The command to install xgboost if you are not installing from source
    pip install xgboost

Steps to reproduce

  1. from xgboost import XGBClassifier
    import numpy as np
    import matplotlib.pyplot as plt
    x = np.array([[1,2],[3,4]])
    y = np.array([0,1])
    clf = XGBClassifier(base_score = 0.005)
    clf.fit(x,y)
    plt.hist(clf.feature_importances_)

What have you tried?

See the error message:
"OMP: 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/."

I tried:
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'

It can do the job for me. But it is kind of ugly.


I know it might be not the problem of xgboost, but I'm pretty sure this problem happened after I upgrade xgboost using 'pip install xgboost'. I post the issue here to see if someone had the same problem as me. I have very little knowledge about OpenMP. Please help!
Thanks in advance!

@staubda
Copy link

staubda commented Nov 9, 2016

I'm having the same issue when I try to use both xgboost and matplotlib.

OS X 10.10.5
Python 2.7.12
xgboost 0.6
matplotlib 1.5.1

@jimthompson5802
Copy link

I've encountered the same problem with xgboost and matplotlib. Same symptom...kernel dies with the same error message as reported by @symPhysics

Mac OS X 10.12.3

Python 3.5.2 |Anaconda custom (x86_64)| (default, Jul 2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin

xgboost 0.6a2

matplotlib 2.0.0

@jimthompson5802
Copy link

FWIW...this seems to be a MacOS specific problem. I was not able to recreate the problem on a CentOS Linux VM.

@ilovejs
Copy link

ilovejs commented Jul 6, 2017

At least for Mac,

brew uninstall libiomp clang-omp

as long as u got gcc v5 from brew it come with openmp

follow steps in:
https://github.com/dmlc/xgboost/tree/master/python-package

We can close this issue now.

@deltaoui
Copy link

I tried this and the error stopped !

import os

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

@JamieGainer
Copy link

For me the issue (on a Mac) was fixed with
pip uninstall xgboost
followed by
pip install xgboost

@Toooodd
Copy link

Toooodd commented Nov 9, 2018

I tried this and the error stopped !

import os

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

thanks, it works!!!

@gpetty
Copy link

gpetty commented Nov 15, 2018

I had the same error on my Mac with a python program using numpy, keras, and matplotlib. I solved it with 'conda install nomkl'.

@swxu
Copy link

swxu commented Nov 17, 2018

I had the same error on my Mac with a python program using numpy, keras, and matplotlib. I solved it with 'conda install nomkl'.

thanks a lot, it works.

@csuagui
Copy link

csuagui commented Nov 25, 2018

I had the same error on my Mac with a python program using numpy, keras, and matplotlib. I solved it with 'conda install nomkl'.

Thanks too, it works for me too.

@M-Alami
Copy link

M-Alami commented Nov 27, 2018

@gpetty You sir are a true hero. Thank you!

@ghost
Copy link

ghost commented Nov 28, 2018

@gpetty It works! THANKSSS :))

@christabella
Copy link

Strangely conda install nomkl didn't work for me (don't have libiomp clang-omp installed on Brew either), only

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

could work

@SumNeuron
Copy link

brew uninstall libiomp clang-omp

Error: No such keg: /usr/local/Cellar/libiomp

@kangkang59812
Copy link

I had the same error on my Mac with a python program using numpy, keras, and matplotlib. I solved it with 'conda install nomkl'.

thanks a lot, even though i dont know what is nomkl. It confused me a few days when i run a CNN-RNN model using tensorflow.When i used os.environ['KMP_DUPLICATE_LIB_OK']='True' , it worked, but the program run so slow.You got the right ans.

@Bjvanminnen
Copy link

My issues were completely unrelated to xgboost, but I got here via google so that I'd share for the sake of others.

I am using keras and matplotlib installed via conda. Setting KMP_DUPLICATE_LIB_OK just changed my experience from a warning to an exception/crash. Install nomkl didn't change anything for me. Eventually I downgraded my version of matplotlib and that fixed things for me
conda install matplotlib=2.2.3

@esvhd
Copy link

esvhd commented Dec 22, 2018

For people googling this error, the best solution that I found is listed here.

The site lists two method. I prefer method 1, which is to go into your anaconda3/lib directory and remove the old libiomp5.dylib file. Nice and simple.

@leong985664
Copy link

For people googling this error, the best solution that I found is listed here.

The site lists two method. I prefer method 1, which is to go into your anaconda3/lib directory and remove the old libiomp5.dylib file. Nice and simple.

Please be really careful if you want to try method 1. Everything crashed after I deleted the file and I have to reinstall openmp. Same problem reported in the original csdn link (in Chinese).

@Cuica20
Copy link

Cuica20 commented Dec 30, 2018

Thanks!!
For me on MAC:
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'

@usr-ein
Copy link

usr-ein commented Jan 2, 2019

Had the same problem after switching from homebrew/virtualenv installed numpy/keras/matplotlib/tensorflow to miniconda installed. Solved by running conda install nomkl though I reckon keras (and numpy) wont run as fast as they could if they don't make use of Intel's Math Kernel Lib but at least my code still run so ¯\_(ツ)_/¯

@jms-dipadua
Copy link

@sam1902 that worked for me too -- updating the os.environ variable did not. thanks!

@TVI-BIZ
Copy link

TVI-BIZ commented Jan 13, 2019

have same issue on my Mac
Just run - conda update -n base conda
it install and update needed dependences

@wangcj05
Copy link

Got the same issue on my mac, tried suggested method and it works

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

@daveloui
Copy link

daveloui commented May 9, 2021

I had the same error on my Mac with a python program using numpy, keras, and matplotlib. I solved it with 'conda install nomkl'.

Thanks so much @gpetty !! You're a life saver! :D

@WissenY
Copy link

WissenY commented May 13, 2021

For people googling this error, the best solution that I found is listed here.

The site lists two method. I prefer method 1, which is to go into your anaconda3/lib directory and remove the old libiomp5.dylib file. Nice and simple.

For me, it works! But the file I removed is a little different from yours which is libiomp5md.dll in the path of C:\Users\***\Anaconda3\Library\bin. I think it may caused by installing full package of pytorch by me after installing anaconda. So the better way is to use miniconda or install pytorch by conda install torch torchvision torchaudio

@chestergan
Copy link

I had the same error on my Mac with a python program using numpy, keras, and matplotlib. I solved it with 'conda install nomkl'.

Legend!

@bdytx5
Copy link

bdytx5 commented Oct 29, 2021

I tried this and the error stopped !

import os

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

genius level stuff right here

@Sophal24
Copy link

Sophal24 commented Feb 19, 2022

On Mac M1, conda install nomkl works.
But if it doesn't work for the first time, you should uninstall and install that command again.

conda uninstall nomkl
conda install nomkl

Above didn't fix my issue after update mac os version ❌

these 2 works:

conda uninstall intel-openmp
conda install -c intel openmp

@changhyeonnam
Copy link

changhyeonnam commented Jun 20, 2022

On Mac M1, conda install nomkl works. But if it doesn't work for the first time, you should uninstall and install that command again.

Above didn't fix my issue after update mac os version ❌

these 2 works:

conda uninstall intel-openmp
conda install -c intel openmp

This works for my intel-Mac!. Thanks alot!

@ckgresla
Copy link

Uninstalling and Reinstalling intel-openmp within the Conda Env solved the issue on my Intel Based MacBook

@OtistarSun
Copy link

WissenY

it works, thank u

@justinesommerlatt
Copy link

On Mac M1, conda install nomkl works. But if it doesn't work for the first time, you should uninstall and install that command again.

Above didn't fix my issue after update mac os version ❌

these 2 works:

conda uninstall intel-openmp
conda install -c intel openmp

Thank you so much, it's the only thing that worked for me !!

@teppotk
Copy link

teppotk commented May 9, 2023

Umm, because the conda install nomkl doesn't work on M1 for me, is the correct full process on M1:

conda uninstall intel-openmp
conda install -c intel openmp
conda install nomkl

?

Actually I ran all those 3 and now nothing works. :) I'm actually trying to run AutoGPT on M1, when all the original libiomp5.dylib problem came up.

On Mac M1, conda install nomkl works. But if it doesn't work for the first time, you should uninstall and install that command again.
Above didn't fix my issue after update mac os version ❌
these 2 works:

conda uninstall intel-openmp
conda install -c intel openmp

This works for my intel-Mac!. Thanks alot!

@Sophal24
Copy link

Try this, I just edited it: #1715 (comment)
Update us if it works!

@Jeremy-Niu
Copy link

My solution is

conda uninstall intel-openmp
conda install nomkl

It seems to work well!
Due to package conflicts, I did not do conda install -c intel openmp. My mbp is intel-mac with os 13.3.1.

@chen0143
Copy link

I met the same error(not with xgboost though), and I fix it by change

import numpy 
import torch

to

import torch
import numpy

it seems that import numpy later would solve this problem. But I don't understand why this bug would be fixed in this way .

@mr-fallen-angel
Copy link

mr-fallen-angel commented Jul 3, 2023

I tried this and the error stopped !

import os

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

it doesnt seem to help macOS

@an-1024
Copy link

an-1024 commented Dec 26, 2023

I tried this and the error stopped !

import os

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

It work. Thank You.

@Viditagarwal7479
Copy link

I tried this and the error stopped !
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'

[MacOS]
This was program termination due to segmentation fault.
Through conda I reinstalled pytorch and then also reinstalled torchvision this fixed the issue for me.

@DomizianoScarcelli
Copy link

DomizianoScarcelli commented Mar 19, 2024

I tried this and the error stopped !
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'

[MacOS] This was program termination due to segmentation fault. Through conda I reinstalled pytorch and then also reinstalled torchvision this fixed the issue for me.

This worked for me on my M1!

@AugustNilsson
Copy link

Have people got problems with this solution?

I tried this and the error stopped !

import os

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

It is quite explicitly not recommended
From the original post:
"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."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests