当前位置:   article > 正文

RuntimeError: nms_impl: implementation for device cuda:0 not found.

runtimeerror: nms_impl: implementation for device cuda:0 not found.

2023年12月7日
在跑mmdetection(v3.2.0)的faster RCNN模型时报错:

from mmdet.apis import DetInferencer

inferencer = DetInferencer(model='faster-rcnn_r50_fpn_1x_coco', device='cuda:0')

# print(inferencer.cfg)
# img_path = 'img'
inferencer(inputs='img',
           out_dir='faster_rcnn/results',
           return_vis=True,
           no_save_pred=False,
           batch_size=8
           )
print('done')
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

错误信息如标题所示,提示找不到显卡:
RuntimeError: nms_impl: implementation for device cuda:0 not found.

在该虚拟环境中运行代码检查是否能调用cuda:

import torch

print("是否可用:", torch.cuda.is_available())        # 查看GPU是否可用
print("GPU数量:", torch.cuda.device_count())        # 查看GPU数量
print("torch方法查看CUDA版本:", torch.version.cuda)  # torch方法查看CUDA版本
index = torch.cuda.current_device()
print("GPU索引号:", index)    # 查看GPU索引号
print("GPU名称:", torch.cuda.get_device_name(index))    # 根据索引号得到GPU名称
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

输出表示一切正常:

是否可用: True
GPU数量: 1
torch方法查看CUDA版本: 12.1
GPU索引号: 0
GPU名称: NVIDIA GeForce RTX 4070 Laptop GPU
  • 1
  • 2
  • 3
  • 4
  • 5

检查torch,torchvision,torchaudio各包版本也都对得上(Python 3.8.18):

!pip list
  • 1
torch                     2.1.0+cu121       
torchaudio                2.1.0+cu121       
torchvision               0.16.0+cu121  
  • 1
  • 2
  • 3

解决方法——重装mmcv:

参考此篇博文的评论区:
https://blog.csdn.net/NCEPUDJ/article/details/121882436

mim uninstall mmcv
mim install mmcv
  • 1
  • 2

这里使用mim是因为mmdetection的官方文档里的教程:
https://mmdetection.readthedocs.io/zh-cn/latest/get_started.html
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/261591
推荐阅读
相关标签
  

闽ICP备14008679号