Python 程序遇到 OMP 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/.

解决办法:
在程序的开始添加如下两行代码:
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'
当Python程序遇到OpenMP错误,如'libiomp5md.dll'已初始化,可以尝试在程序开头添加代码设置环境变量'KMP_DUPLICATE_LIB_OK'为'True',以允许程序继续执行,但这种方法可能影响性能或导致不正确结果。最佳做法是确保程序中只链接一次OpenMP运行时库。
1万+

被折叠的 条评论
为什么被折叠?



