Linux下环境配置
创建环境并激活
conda create --name openmmlab python=3.7 -y
conda activate openmmlab
安装Pytorch
建议使用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
MMDetection安装
建议使用 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')
Windows下环境配置
步骤与Linux安装基本相同
创建环境并激活
conda create --name openmmlab python=3.7 -y
conda activate openmmlab
安装Pytorch
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
安装MMDetection
使用下面命令:
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
安装MMCV
下载链接
pip install mmcv==2.0.0rc4 -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.7/index.html