mmdetection 安装(不支持 pytorch 2.2.x)

参考:
https://mmdetection.readthedocs.io/zh-cn/latest/get_started.html

有点坑的是安装 mmcv 时去 https://mmcv.readthedocs.io/en/latest/get_started/installation.html 上面一查,
发现不支持 pytorch 2.2.x(截止 2024.4.5)
按教程的方法装不会报错,但是就是跑不起来程序,真傻逼。


conda create --name openmmlab python=3.10 -y
conda activate openmmlab

先上:
https://pytorch.org/get-started/previous-versions/
装个 pytorch 2.1.0,我本机 CUDA 11.8,所以是:

pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118
pip install -U openmim

装这个 mmengine 随便装。

pip install mmengine

然后去上面找:
https://mmcv.readthedocs.io/en/latest/get_started/installation.html
指令为:

pip install mmcv==2.1.0 -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.1/index.html

最后:

git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -v -e .
# "-v" 指详细说明,或更多的输出
# "-e" 表示在可编辑模式下安装项目,因此对代码所做的任何本地修改都会生效,从而无需重新安装。

然后跑跑这个代码:

from mmdet.apis import DetInferencer

# 初始化模型
inferencer = DetInferencer('rtmdet_tiny_8xb32-300e_coco')

# 推理示例图片
inferencer('../mmdetection/demo/demo.jpg', out_dir='outputs/', no_save_pred=False)

能正常输出就没有问题了

posted @ 2024-04-05 21:19  Cold_Chair  阅读(42)  评论(0编辑  收藏  举报