由于官方提供的win版本有限,需要自己源码编译mmcv,特此记录。
1 准备
提前下载好mmcv-master.zip或者gi clone下来:
还有提前下载好mmflow-master.zip
安装:
Visual Studio Community 2019
Anaconda3
cuda11.1
2 安装python环境
conda create --name mmcv python=3.7 # 3.6, 3.7, 3.8 should work too as tested conda activate mmcv # make sure to activate environment before any operation
torch-1.8.0+cu111-cp37-cp37m-win_amd64.whl
https://download.pytorch.org/whl/cu111/torch-1.8.0%2Bcu111-cp37-cp37m-win_amd64.whlhttps://download.pytorch.org/whl/cu111/torch-1.8.0%2Bcu111-cp37-cp37m-win_amd64.whltorchvision-0.9.0+cu111-cp37-cp37m-win_amd64.whl
pip install torch-1.8.0+cu111-cp37-cp37m-win_amd64.whl
pip install torchvision-0.9.0+cu111-cp37-cp37m-win_amd64.whl
cd mmcv
pip install -r requirements.txt
3 编译mmcv
严格按照官网要求设置
(0)Set up MSVC compiler
测试是否配置成功:
(1)cuda
安装了cuda,环境变量自己会有
(2) CUDA target arch
查询自己的gpu算力,我的是3090,算力是8.6
(3)ops和cpu cores
然后开始编译
conda activate mmcv # change directory cd mmcv # build python setup.py build_ext # if success, cl will be launched to compile ops
编译成功:
如何没有打印很多信息,则是失败了,重新确认一遍流程。
安装mmcv:
# install python setup.py develop # check pip list
安装成功:
发现,mmcv和mmcv-full都有。
注:
如果输入conda list,报错
CondaError: Expected exactly one `egg-info` directory in 'D:\code\PycharmProjects\mmcv'
则删除conda环境中的文件mmcv-full.egg-link