前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >OMP Error 15 Initializing libiomp5md.dll, but found libiomp5md.dll already initialized 解决方案

OMP Error 15 Initializing libiomp5md.dll, but found libiomp5md.dll already initialized 解决方案

作者头像
为为为什么
发布2022-08-05 15:43:49
1.7K0
发布2022-08-05 15:43:49
举报
文章被收录于专栏:又见苍岚又见苍岚

在python调用matplotlib时有时会报错 OMP Error 15 Initializing libiomp5md.dll, but found libiomp5md.dll already initialized,本文记录解决方案。

错误复现

  • 报错信息:OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized
代码语言:javascript
复制
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/.

问题原因

  • 可能是从不同位置加载了 libiomp5md.dll 库,触发了某种自检,报出了错误

解决方案

方案1
  • 忽略该错误,在环境变量中加入 KMP_DUPLICATE_LIB_OK 设置为 True
代码语言:javascript
复制
import os
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"

通常 libiomp5md.dll 库没有特殊的变化,从不同位置加载其行为也是相同的,是大家广泛采取的解决方案

方案2
  • 在运行的python环境中搜索 libiomp5md.dll 文件,删除多余的文件,仅保留 torch 中的库可以避免这个错误
  • 不过可能会造成其他未知的问题(我就是在删除之后 matplotlib 再也打不出图像了)
  • 删除文件需要谨慎

参考资料

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021年7月23日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 错误复现
  • 问题原因
  • 解决方案
    • 方案1
      • 方案2
      • 参考资料
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档