cuda11.3配置open-mmlab环境记录

cuda11.3配置open-mmlab环境记录

环境为Linux

conda create -n open-mmlab python=3.7 -y
conda activate open-mmlab

# 从https://download.pytorch.org/whl/cu113/torch_stable.html下载以下文件
# torch-1.11.0+cu113-cp37-cp37m-linux_x86_64.whl
# torchaudio-0.11.0+cu113-cp37-cp37m-linux_x86_64.whl
# torchvision-0.12.0+cu113-cp37-cp37m-linux_x86_64.whl
# 之后直接使用pip安装
pip install torch-1.11.0+cu113-cp37-cp37m-linux_x86_64.whl -i http://mirrors.aliyun.com/pypi/simple/  --trusted-host mirrors.aliyun.com
pip install torchaudio-0.11.0+cu113-cp37-cp37m-linux_x86_64.whl -i http://mirrors.aliyun.com/pypi/simple/  --trusted-host mirrors.aliyun.com
pip install torchvision-0.12.0+cu113-cp37-cp37m-linux_x86_64.whl -i http://mirrors.aliyun.com/pypi/simple/  --trusted-host mirrors.aliyun.com
# 此时运行torch.cuda.is_available()可以看到为true

# 安装 mmcv-full
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.0/index.html

# 安装 MMDetection
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e .  # or "python setup.py develop"

# 之后运行官方的验证代码可以运行
from mmdet.apis import init_detector, inference_detector

config_file = '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 = 'checkpoints/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')

你可能感兴趣的:(深度学习,目标检测,pytorch)