Bbest Nichapa
Bbest Nichapa

Reputation: 111

Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized

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?

Upvotes: 10

Views: 35025

Answers (8)

ZFox
ZFox

Reputation: 1

I had the same issue. There were multiple "libiomp5md.dll" files inside the environment, one in the root of the environment folder and another in lib\site-packages\torch\lib. I deleted the libiomp5md.dll in the root folder, and it started working fine.

Upvotes: 0

himothy
himothy

Reputation: 103

I was able to resolve this by upgrading numpy, then using the "Start Locally" page of pytorch to install pytorch and all its correct dependencies.

Upvotes: 0

Lou Nascimento
Lou Nascimento

Reputation: 1

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

enter image description here

Upvotes: -1

Hupsi
Hupsi

Reputation: 1

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.

Upvotes: -2

falozzo
falozzo

Reputation: 161

I solved this by upgrading NumPy to version 1.23.4.

pip install numpy --upgrade

This works fine for me :)

Upvotes: 16

Iaoceot
Iaoceot

Reputation: 444

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

Upvotes: 11

William Ramsey
William Ramsey

Reputation: 91

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/

Upvotes: 9

S. Chang
S. Chang

Reputation: 31

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.

Upvotes: 3

Related Questions