7

Operating System: Window10

I use spyder (python3.8) in anaconda and after run the code, I get the following error:

[SpyderKernelApp] WARNING | No such comm: df7601e106dd11eba18accf9e4a3c0ef

OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll 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/.

How do I fix this?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Bbest Nichapa
  • 81
  • 1
  • 1
  • 3
  • 1
    Not sure if it will help you, but in my case, (I had exactly the same error) the culprit was a module, more specifically the `import` statement. I moved it a few lines lower and the error went away. Apparently it matters which functions have already been imported. – Aenaon Oct 13 '20 at 20:17
  • Does this answer your question? [sklearn OMP: Error #15 ("Initializing libiomp5md.dll, but found mk2iomp5md.dll already initialized.") when fitting models](https://stackoverflow.com/questions/20554074/sklearn-omp-error-15-initializing-libiomp5md-dll-but-found-mk2iomp5md-dll-a) – Wai Ha Lee Sep 09 '21 at 11:40

6 Answers6

9
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'
Iaoceot
  • 384
  • 4
  • 9
9

This error occurs when there are multiple "libiomp5.dll" files within a python interpreter. I fixed it by deleting all of the versions of the file that were not within the module I was using (PyTorch). I would like to point out that this could cause a lot of multiprocessing issues down the road if you don't know what you are doing but I am sure it is nothing that can't be solved by looking it up on StackOverflow.

For more details visit: https://www.programmersought.com/article/53286415201/

5

I solved this by upgrading NumPy to version 1.23.4.

pip install numpy --upgrade

This works fine for me :)

falozzo
  • 51
  • 1
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 18 '22 at 01:57
  • Works for me too! You're amazing. Such a simple solution. – bobt Apr 28 '23 at 19:15
3

I'm not sure if this has been solved and you've moved on, but I just encountered this as well and was able to fix it with reinstalling a package with pip.

My machine has an AMD Ryzen 5 3400G CPU, and I frequently do machine learning and deep learning for university research. I first had this problem yesterday when I created a Tensorflow anaconda environment when I already had a separate PyTorch environment. I was also incorporating a colleague's code into mine, so I believe what Aenaon commented is valid, that what is imported matters.

Anyway, my solution - after researching where mkl is used - was to repeatedly pip uninstall and pip install one mkl-dependent package at a time until the problem went away when running my program. Somehow it was resolved after doing this the first time for numpy. I think it's coincidence, but my desired program works for now without any problems.

Dharman
  • 30,962
  • 25
  • 85
  • 135
S. Chang
  • 31
  • 2
  • worked for me on window 10 with python 3.6 using Conda env but installing (almost) all packages using pip. Uninstalling/installing numpy/scipy/matplotlib using pip did the trick for me. – odedbd Sep 13 '21 at 06:03
-1

I was able to fix it by moving import HELPERS late and plus adding the import OS too.

enter image description here

4b0
  • 21,981
  • 30
  • 95
  • 142
  • 1
    Please do not post image of the source code. It is difficult to adopt by someone who wants to try this answer. Post it as a code block. – Azhar Khan Dec 01 '22 at 04:35
-2

Had the same problem with

  • Anaconda Navigator 2.3.2
  • Spyder version: 5.3.3 (conda)
  • Python version: 3.9.15 64-bit
  • Qt version: 5.15.2
  • PyQt5 version: 5.15.7
  • Operating System: Windows 10

I detected libiomp5md.dll in:

  • ..\anaconda3\envs\My_Env\Library\bin
  • ..\anaconda3\pkgs\tensorflow-base-2.9.1-mkl_py39h6a7f48e_1\Lib\site-packages\tensorflow\python

I renamed the one in ..\envs\My_Env\Library\bin to libiomp5_save.dll.

and everything was fine.

Don't know if there are any side effects.

Azhar Khan
  • 3,829
  • 11
  • 26
  • 32
Hupsi
  • 1
  • 1