目標檢測常用庫MMCV安裝中遇到的問題總結

  • 2022 年 3 月 14 日
  • 筆記

我看很多教程說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": //visualstudio.microsoft.com/downloads/ Tools":

建議是直接離線包下載安裝:

離線包我這裡給大家一個百度網盤的連接,大家自行下載即可
鏈接://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

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

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

一定要把數字改成對應你的版本,不然安裝成功後一九無法運行,會報import error:DLL load failed