```
conda create --name TargetD python==3.7
activate TargetD
```
安装cuda11.0对应的版本:
```
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=11.0 -c pytorch
```
将C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x64添加到系统的环境变量中。
测试是否成功:
C:\Users\Administrator>cl
用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30037 版
版权所有(C) Microsoft Corporation。保留所有权利。
用法: cl [ 选项... ] 文件名... [ /link 链接选项... ]
在进行如下操作时,一定要进入cmd,然后activate TargetD,不要在anaconda prompt下进行。
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
git checkout v1.3.13
pip3 install -r requirements.txt
配置环境变量:
CUDA_PATH的路径一般在安装CUDA时就自动添加了,如果没有就自己添加
继续在系统变量中添加如下环境变量:
变量名称:MMCV_WITH_OPS,值:1
变量名称:MAX_JOBS,值:4
变量名称:TORCH_CUDA_ARCH_LIST,值:8.0 (尤为重要)
针对8.0的解释,这个为GPU的算力值,查看算力值,方法如下:
可以看到,我的GPU算力值为8.6,由于CUDA的版本对算力值有要求,所以针对cuda11.0,将算力值设为8.0。本人测试过8.6以及7.5都失败
```
# build
python setup.py build_ext # if success, cl will be launched to compile ops
```
出现错误:
RuntimeError: Error compiling objects for extension
解决方法:
修改对应env(TargetD)下Lib\site-packages\torch\utils\cpp_extension.py
self.use_ninja = kwargs.get('use_ninja', True)
改为
self.use_ninja = kwargs.get('use_ninja', False)
然后依次执行:
python setup.py build_ext --inplace
正确的是显示 running build_ext,然后
pip install -e .
安装成功后,继续进行环境安装:
# install
python setup.py develop
检查安装情况:
(base) H:\test\mmcv>pip show mmcv-full
Name: mmcv-full
Version: 1.3.13
Summary: OpenMMLab Computer Vision Foundation
Home-page: https://github.com/open-mmlab/mmcv
Author: MMCV Contributors
Author-email: [email protected]
License: UNKNOWN
Location: h:\test\mmcv
Requires: addict, numpy, packaging, Pillow, pyyaml, yapf, regex
Required-by:
在 mmcv 文件夹里会有一个 _ext.cp37-win_amd64.pyd文件生成
链接:https://download.csdn.net/download/qq_44747572/85115153
swin transformer的源码:
https://github.com/SwinTransformer/Swin-Transformer-Object-Detection
mmcv的安装:
https://github.com/open-mmlab/mmcv
https://www.zywvvd.com/notes/environment/cuda/windows-mmcv-1-3-13-install/windows-mmcv-1-3-13-install/
https://blog.csdn.net/lebusini/article/details/117525764
https://blog.csdn.net/Dorisxd/article/details/121418280
https://blog.csdn.net/chen_yanan/article/details/123866039
https://blog.csdn.net/weixin_43678195/article/details/123574385