跑DRL程序要使用matplotlib绘制曲线图时报错。
错误如下:
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/.
提示:这意味着 OpenMP 运行时的多个副本已链接到程序中。这很危险,因为它会降低性能或导致不正确的结果。最好的办法是确保只有单个 OpenMP 运行时链接到进程中,例如,避免在任何库中静态链接 OpenMP 运行时。还有一种不安全、不受支持、未记录的解决方法,您可以将环境变量 KMP_DUPLICATE_LIB_OK=TRUE 设置为允许程序继续执行,但这可能会导致崩溃或以静默方式产生不正确的结果。
解决方案:
法一:
在程序开头插入代码:
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'
GPT解释:
设置环境变量KMP_DUPLICATE_LIB_OK的值为True。这个环境变量通常用于控制Intel MKL库的行为,设置为True可以允许多个线程同时使用该库,避免出现冲突和错误。
法二:
在当前程序的环境中搜索libiomp5md.dll文件,将之移除
补充:libiomp5md.dll是Intel OpenMP(Open Multi-Processing)运行时库的一部分。OpenMP是一种并行编程模型,用于在共享内存系统中进行并行计算。libiomp5md.dll文件包含了用于支持OpenMP并行编程的函数和工具,可以在程序运行时加载并使用这些函数和工具。它提供了对并行计算的支持,能够在多核处理器上有效地执行并行化的计算任务。