创建环境并激活
conda create --name openmmlab python=3.7 -y
conda activate openmmlab
建议使用pip命令安装,否则会报错:
symbol free_gemm_select version libcublasLt.so.11 not defined in file
libcublasLt.so.11 with link time reference
pip install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=11.0 -c pytorch
建议使用 MIM 来安装 MMDetection:
pip install openmim
mim install mmdet
MIM 能够自动地安装 OpenMMLab 的项目以及对应的依赖包。
或者可进行手动安装
安装MMCV需要对应CUDA和torch,安装命令要符合下面格式:
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html
如安装CUDA1.0,pytorch=1.7.0:
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html
简单测试
from mmdet.apis import init_detector, inference_detector
config_file = '/data/programs/mmdetection/mmdetection/configs/faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py'
# 从 model zoo 下载 checkpoint 并放在 `checkpoints/` 文件下
# 网址为: http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
checkpoint_file = '/data/programs/mmdetection/mmdetection/checkpoint/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
# 初始化检测器
model = init_detector(config_file, checkpoint_file, device=device)
# 推理演示图像
inference_detector(model, 'demo/demo.jpg')
步骤与Linux安装基本相同
创建环境并激活
conda create --name openmmlab python=3.7 -y
conda activate openmmlab
pip install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
使用下面命令:
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e .
pip install openmim -i https://pypi.tuna.tsinghua.edu.cn/simple
mim install mmdet
如果执行pip install openmim
可能会报下方错误
to fix this you could try to: 1. loosen the range of package versions
you’ve specified 2. remove package versions to allow pip attempt to
solve the dependency conflict
否则会报错超时,依旧报错
mim install mmdet -i https://pypi.tuna.tsinghua.edu.cn/simple
下载链接
pip install mmcv==2.0.0rc4 -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.7/index.html
这里一定要对应好版本,先前博主一致安装的是cuda110,一直报错,直到改为cu101才能够成果安装。
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.7.0/index.html
torch1.7版本以下不支持分布式训练,故需要安装torch1.7以上
报错1:
ext = importlib.import_module(‘mmcv.’ + name) File
“D:\Anaconda\envs\openmmlab\lib\importlib_init_.py”, line 127, in
import_module
return _bootstrap._gcd_import(name[level:], package, level) ImportError: DLL load failed: 找不到指定的模块。