Ran into this issue while executing

Hi,
I recently came across this post mentioned in the below link
https://towardsdatascience.com/the-one-pytorch-trick-which-you-should-know-2d5e9c1da2ca

When I ran the code mentioned in the link,I ran into the following error
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/.
[SpyderKernelApp] WARNING | No such comm: 226297d71da911eb95ceaced5c5490c5
Notice that when the following lines were added
import os
#os.environ[“KMP_DUPLICATE_LIB_OK”]=“TRUE”
the issue would disappear.Any ideas why this is happening and what can be done to get around this issue?
Pytorch was installed using the command
pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
System config Windows 10 CPU intel i5
Python 3.8.3

Hye,
I also ran in the same trouble.
Found any strong solution?

you can refer to this
since i prefer quick fixes,i went with

import os
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"

but the correct solution is to create a seperate environment,and in that you must install all your packages

Hye!
I did that, it was fixed for the time being.

But I didn’t like the aesthetic of it. So, after going through a bit, I just reinstalled pytorch but with a downgraded version (1.7.1). No issues after that. Some pointy bugs I guess with Python version 3.8 and above with Pytorch version 1.9.

1 Like