【解决30、40系列显卡使用mmrotate出现nvcc fatal: Unsupported gpu architecture ‘compute_86‘及size mismatch报错】

解决30、40显卡训练出现sm_86

报错如下:

nvcc fatal: Unsupported gpu architecture 'compute_86'

主要原因是mmrotate教程推荐的pytorch版本太低,因此需要保证当前使用的torch
和cuda版本适配30、40系列的显卡,而mmcv也必须重新安装适配torch的版本。

conda install pytorch==1.8.0 torchvision==0.9.0 cudatoolkit=10.2 -c pytorch #mmrotate官方推荐的版本太低,实测要保证pytorch版本>=2.0.0

若不知道当时安装的哪个版本,可通过如下命令查看torch及cuda版本:

python -c 'import torch;print(torch.__version__);print(torch.version.cuda)'  

Facebook在2021年推出了pytorch1.8.0版本,而英伟达第一个型号的40系列显卡是在22年发布,因此需要更高的torch版本来支持更高版本的sm_86架构(即更高版本的cuda)。
实测安装torch2.0.0、cuda11.8和mmcv-full1.7.2,比较适配英伟达的GTX4060TI显卡(torch和cuda版本必须匹配,安装教程请另找)
通过如下的命令可安装特定版本的mmcv–full:

pip install mmcv-full==1.7.2 -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.0.0/index.html

如果是其它版本的torch和cuda,安装较低版本的mmcv–full,只需修改后面的网址就行(可进入该网址查看有哪些版本的mmcv提供):

pip install mmcv-full==1.7.0 -f https://download.openmmlab.com/mmcv/dist/cu117/torch1.13/index.html

推理及size mismatch报错

修改MyTest.py的模型地址和待检测的图像地址:

# Choose to use a config and initialize the detector
config = 'oriented_rcnn_r50_fpn_1x_dota_le90.py'
# Setup a checkpoint file to load
checkpoint = 'tutorial_exps/latest.pth'
...
# Use the detector to do inference
img = './MyData/SOP8_DOTA_Label/images/png格式/SOP8_4.png '
result = inference_detector(model, img)

点击运行MyTest.py出现如下报错:

size mismatch for roi_head.bbox_head.fc_cls.weight: copying a param with shape torch.Size([2, 1024]) from checkpoint, the shape in current model is torch.Size([16, 1024]).

原因是config文件中的roi_head字典内设定的物体检测的类数量不一致,如果模型只有一个类,则修改如下:

        num_classes=1,
        reg_class_agnostic=True,
        roi_feat_size=7,
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值