首页 > 技术文章 > win10中安装mmcv和mmdetection的问题

aimhabo 2020-12-11 11:23 原文


目前环境:vs2019preview-2.0(14.28.29617+python3 32位 64位),cuda10.2,torch1.6.0,torchvision0.7.0,mmcv-1.1.5,mmdetection-2.7.0

 

新版本里编译安装在我的电脑上不可行,以下跳过,直接看第0. 步

先命令行里运行一下ninja -v,然后添加到防火墙的白名单中。

 

由于cl的编码问题,需要修改:D:/ProgramData/Anaconda3/envs/mmlabv2/Lib/site-packages/torch/utils/cpp_extension.py中的

match = re.search(r'(\d+)\.(\d+)\.(\d+)', compiler_info.decode().strip())

改为(注意有空格)

match = re.search(r'(\d+)\.(\d+)\.(\d+)', compiler_info.decode(" gbk").strip())

(如果还找不到cl的话,建议在VS的安装目录内搜索cl.exe,然后把目录,添加到环境变量PATH内,mmcv编译时使用x86内的那套x64,

PATH新增内容形如C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29617\bin\Hostx86\x64 (先行版用户的文件夹可能不是Community而是Preview),每次更新后注意VS版本号变化)

 

安装过程:

0. 注意要使用Anaconda PowerShell prompt而不是CMD或者VS/VSCode内的命令行。编译安装可以尝试删除线内的内容输入以下信息进行变量预设 6.1是显卡算力,视具体显卡而定

$env:TORCH_CUDA_ARCH_LIST="6.1"
$env:MMCV_WITH_OPS = 1
$env:MAX_JOBS = 4

1. mmcv在github中tag到1.2.1,在解压后的目录内,python setup.py build_ext 然后 python setup.py develop

直接安装预编译文件,在https://download.openmmlab.com/mmcv/dist/index.html中下载./1.1.5/torch1.6.0/cu102/mmcv_full-1.1.5+torch1.6.0+cu102-cp37-cp37m-win_amd64.whl

使用pip本地安装这个文件

 

2. cocoapi中进入到PythonAPI目录, python setup.py install

 

3. mmdetection在github中tag到2.7.0,解压后的目录内,pip install -r requirements/build.txt 然后 python setup.py develop

 

 

 

参考:https://mmcv.readthedocs.io/en/latest/build.html

推荐阅读