目标检测常用库MMCV安装中遇到的问题总结

我看很多教程说mmcv是只支持linux,支持windows版本较少,所以很难和torch、cuda匹配上,所以报错较多难安装。今天试了一下,遇到的和想到的报错问题基本如下:

一、首先是Microsoft Visual C++ 14.0 is required:

error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ Tools":

建议是直接离线包下载安装:

离线包我这里给大家一个百度网盘的连接,大家自行下载即可
链接:https://pan.baidu.com/s/1ytKIVSBXLMQhrXleC_I4dA

提取码:8scp

二、直接pip install一片红

这是github上官方推荐的方法,然后pycharm直接报错:

Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.


PackagesNotFoundError: The following packages are not available from current channels:

  - mmcv

Current channels:
To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.
.......

建议是先安装mmcv离线包,然后再装mmdet

安装如果继续报错,查看报错代码中是否存在上一个问题

三、MMCV和MMDET都安装成功了,运行报错importError

ImportError: DLL load failed: 找不到指定的模块

image-20220313212809816

这个一般是说加载动态链接库有问题,先查看是否能import mmcv

和import mmdet

如果成功,说明应该是版本不匹配,去查看自己torch和cuda版本,然后看一下mmdet和mmcv版本匹不匹配,再去离线包地方下载相应版本的库。离线版本教程在后面

如果失败,说明库根本没安装到位,去pip list下看一看是否装上。

给出mmdet版本和mmcv版本对应图:

MMDetection 版本 MMCV 版本
master mmcv-full>=1.3.17, <1.5.0
2.22.0 mmcv-full>=1.3.17, <1.5.0
2.21.0 mmcv-full>=1.3.17, <1.5.0
2.20.0 mmcv-full>=1.3.17, <1.5.0
2.19.1 mmcv-full>=1.3.17, <1.5.0
2.19.0 mmcv-full>=1.3.17, <1.5.0
2.18.1 mmcv-full>=1.3.17, <1.4.0
2.18.0 mmcv-full>=1.3.14, <1.4.0
2.17.0 mmcv-full>=1.3.14, <1.4.0
2.16.0 mmcv-full>=1.3.8, <1.4.0
2.15.1 mmcv-full>=1.3.8, <1.4.0
2.15.0 mmcv-full>=1.3.8, <1.4.0
2.14.0 mmcv-full>=1.3.8, <1.4.0
2.13.0 mmcv-full>=1.3.3, <1.4.0
2.12.0 mmcv-full>=1.3.3, <1.4.0
2.11.0 mmcv-full>=1.2.4, <1.4.0
2.10.0 mmcv-full>=1.2.4, <1.4.0
2.9.0 mmcv-full>=1.2.4, <1.4.0
2.8.0 mmcv-full>=1.2.4, <1.4.0
2.7.0 mmcv-full>=1.1.5, <1.4.0
2.6.0 mmcv-full>=1.1.5, <1.4.0
2.5.0 mmcv-full>=1.1.5, <1.4.0
2.4.0 mmcv-full>=1.1.1, <1.4.0
2.3.0 mmcv-full==1.0.5
2.3.0rc0 mmcv-full>=1.0.2
2.2.1 mmcv==0.6.2
2.2.0 mmcv==0.6.2
2.1.0 mmcv>=0.5.9, <=0.6.1
2.0.0 mmcv>=0.5.1, <=0.5.8

四、ModuleNotFoundError

安装了多个版本的mmcv,pip list中看一下,之后卸载掉一个。

五、离线包上哪找?

image-20220313213656360

很多人pip 有问题,那么直接打开这个链接去找你的python版本

例如cu1.10,torch1.7.0:

https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html

一定要把数字改成对应你的版本,不然安装成功后一九无法运行,会报import error:DLL load failed