Java开发

报错 OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized

2025-02-21 48 0

简介 报错 OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized


(llama_factory) C:\Users\>python -c "import torch; print(torch.__version__)"
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运行时(libiomp5md.dll)。该问题常在Windows平台上出现,并且通常是因为多个使用OpenMP加速的库(如PyTorch、timm、MKL) 、PyWavelets 等)被同时加载,导致重复加载相同运行时库。

解决:

方法一:

一般采用以下方式:
import os
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE

但是这种方式治表不治里,在下一个项目运行中还有可能出行同样的问题。

 

方法二:

如果在Anaconda的base环境下:删除..\Anaconda3\Library\bin\libiomp5md.dll

如果是在某个env(例如名为work)下:删除..\Anaconda3\envs\work\Library\bin\libiomp5md.dll

点赞 0

我的名片

网名:梦宇信息技术

职业:软件开发、Mes系统工程师

现居:福建省-福州市

QQ:703159

站点信息

  • 联系QQ:703159
  • 文章统计97篇文章
  • 标签总数6
  • 加我微信:扫码,加我微信