在进行机器学习【pytorch框架】的时候,有事会报如下错,以前我是通过削减Batch_size值,自己仔细想了想,这样做未免有点不解决根本问题,系统报错提示:
KMP_DUPLICATE_LIB_OK=TRUE 可以解决,我顺势查阅了下 KMP_DUPLICATE_LIB_OK=TRUE 。得到的二级结论如下:
这个有可能是因为系统环境中存在多个版本的OpenMP库导致,可以把环境变量KMP_DUPLICATE_LIB_OK设置成True试试。
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'
或:
- 查看文件链接的OpenMP library, 只使用一个。
- 推荐使用动态库:libiomp5md.dll
- 如果第三方库使用libguide40.dll, 使用libiomp5md.dll 重新编译库文件。