OMP: Error #15: Initializing lib

2021-10-30  本文已影响0人  LabVIEW_Python

问题:在Anaconda下运行PyTorch程序,出现报错如下:

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.

原因:torch包中包含了名为libiomp5md.dll的文件,与Anaconda环境中的同名文件libiomp5md.dll出现了冲突

重名冲突
解决方案:在PyTorch代码中加入两行语句,设置环境变量KMP_DUPLICATE_LIB_OK=TRUE
import os
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
上一篇 下一篇

猜你喜欢

热点阅读