ubuntu mmdetection配置

mmdetection配置最重要的是版本匹配,特别是cuda,torch与mmcv-full

本项目以mmdetection v2.28.2为例介绍

1.查看显卡算力

因为gpu的算力需要与Pytorch依赖的CUDA算力匹配,低版本GPU可在相对高的CUDA版本下运行,相反则不行

算力不匹配运行torch训练会报如下错误:

CUDA error: no kernel image is available for execution on the device

ubuntu mmdetection配置_第1张图片

torch和cuda适配信息参考链接

我们用的显卡是A40和4080,其中4080算力8.9,A40算力8.6

2. cuda安装


根据显卡算力,cuda选择用11.6版本

下载链接

添加权限

chmod 700 cuda_11.6.0_510.39.01_linux.run

安装

sh chmod 700 cuda_11.6.0_510.39.01_linux.run

注意要将driver取消,即按空格显示不执行即可

3.安装对应版本的torch1.13.0

参考链接

pip install torch==1.13.0+cu116 torchvision==0.14.0+cu116 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu116

ps:可以通过如下命令查看torch与cuda算力是否匹配

>>> import torch
torch.cuda.get_arch_list()
>>> torch.cuda.get_arch_list()
['sm_37', 'sm_50', 'sm_60', 'sm_70', 'sm_75', 'sm_80', 'sm_86']
>>> torch.__version__
'1.13.0+cu116'

torch1.13.0+cu116可支持sm_86,在A40和4080上都可以运行

4.下载安装mmdetection

参考链接

git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -v -e . -i https://pypi.tuna.tsinghua.edu.cn/simple

5. 下载安装mmcv-full

参考链接

pip install mmcv-full==1.7.1 -f https://download.openmmlab.com/mmcv/dist/cu116/torch1.13.0/index.html

ps:

mmcv和mmcv-full只需要安装一个即可,两个都安装会报各种module找不到错误
mmcv-full最高只有1.7.1版本,且不支持torch1.13.1,torch2.0对应mmcv,没有mmcv-full了
对于本篇博客配置的mmdetection来说,安装mmcv会报找不到runner错误
ubuntu mmdetection配置_第2张图片

参考链接:
yolov5训练加速--一个可能忽视的细节(mmdetection也一样),为什么显卡使用率老是为0?_kv1830的博客-CSDN博客

解决CUDA error: no kernel image is available for execution on the device-CSDN博客

pytorch 报错 RuntimeError: CUDA error: no kernel image is available for execution on the device_可豌豆的博客-CSDN博客

你可能感兴趣的:(ubuntu,深度学习,linux)