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

1、解决OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.报错问题

错误如下所示:

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/.

解决办法1:

在pycharm里调试程序时可以直接通过在程序前添加这两个语句解决

import os
os.environ[“KMP_DUPLICATE_LIB_OK”]=“TRUE”

解决办法2:

办法1不能解决问题的话,甚至直接在terminal上import torch也会出现这种问题:

究其原因其实是,anaconda的环境下存在两个libiomp5md.dll文件。所以直接去虚拟环境的路径下搜索这个文件,可以看到在环境里有两个dll文件:

其中第一个是torch路径下的,第二个是虚拟环境本身路径下的,转到第二个目录下把它剪切到其他路径下备份就好(最好把路径也备份一下)。

2、ModuleNotFoundError: No module named ‘mmcv._ext‘解决方案

使用目标检测开源工具MMDetection时,出现如下报错:

ModuleNotFoundError: No module named 'mmcv._ext'

很有可能是你在开始安装mmcv-full的时候,没有指定版本,选择直接安装,如下:

pip install mmcv-full

采用这样默认安装mmcv-full的方式,如果与你环境里的cuda和torch版本不匹配,就容易出现上面报错

卸载掉原来的mmcv

pip uninstall mmcv-full

重新安装正确版本的mmcv-full

其中,{cu_version}、{torch_version}分别对应cuda和torch的版本号

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html

例如,我安装的是cuda10.2、pytorch1.8.0,所以应该输入命令:

pip install mmcv-full==1.2.4 -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.8.0/index.html

注意:mmcv-full我这里推荐用1.2.4版本的。

你可能感兴趣的:(mmdetection,深度学习)