網(wǎng)頁游戲排行榜3d商丘網(wǎng)站優(yōu)化公司
mmdetection配置最重要的是版本匹配,特別是cuda,torch與mmcv-full
本項(xiàng)目以mmdetection v2.28.2為例介紹
1.查看顯卡算力
因?yàn)間pu的算力需要與Pytorch依賴的CUDA算力匹配,低版本GPU可在相對高的CUDA版本下運(yùn)行,相反則不行
算力不匹配運(yùn)行torch訓(xùn)練會報(bào)如下錯誤:
CUDA error: no kernel image is available for execution on the device
torch和cuda適配信息參考鏈接
我們用的顯卡是A40和4080,其中4080算力8.9,A40算力8.6
2. cuda安裝
根據(jù)顯卡算力,cuda選擇用11.6版本
下載鏈接
添加權(quán)限
chmod 700?cuda_11.6.0_510.39.01_linux.run
安裝
sh chmod 700?cuda_11.6.0_510.39.01_linux.run
注意要將driver取消,即按空格顯示不執(zhí)行即可
3.安裝對應(yīng)版本的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上都可以運(yùn)行
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只需要安裝一個即可,兩個都安裝會報(bào)各種module找不到錯誤
mmcv-full最高只有1.7.1版本,且不支持torch1.13.1,torch2.0對應(yīng)mmcv,沒有mmcv-full了
對于本篇博客配置的mmdetection來說,安裝mmcv會報(bào)找不到runner錯誤
參考鏈接:
yolov5訓(xùn)練加速--一個可能忽視的細(xì)節(jié)(mmdetection也一樣),為什么顯卡使用率老是為0?_kv1830的博客-CSDN博客
解決CUDA error: no kernel image is available for execution on the device-CSDN博客
pytorch 報(bào)錯 RuntimeError: CUDA error: no kernel image is available for execution on the device_可豌豆的博客-CSDN博客