python detect.py --weights yolov7.pt --conf 0.25 --img-size 640 --source inference/images/horses.jpg
Namespace(weights=['yolov7.pt'], source='inference/images/horses.jpg', img_size=640, conf_thres=0.25, iou_thres=0.45, device='', view_img=False, save_txt=False, save_conf=False, nosave=False, classes=None, agnostic_nms=False, augment=False, update=False, project='runs/detect', name='exp', exist_ok=False, no_trace=False)
YOLOR 52f8176 torch 2.1.1+cu118 CUDA:0 (NVIDIA GeForce GTX 1650, 4095.75MB)
Fusing layers...
RepConv.fuse_repvgg_block
RepConv.fuse_repvgg_block
RepConv.fuse_repvgg_block
C:\Users\aleja\anaconda3\envs\yolov7-gpu-env\lib\site-packages\torch\functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ..\aten\src\ATen\native\TensorShape.cpp:3527.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
Model Summary: 306 layers, 36905341 parameters, 6652669 gradients, 104.5 GFLOPS
Convert model to Traced-model...
traced_script_module saved!
model is traced!
Traceback (most recent call last):
File "C:\yolov7-gpu\detect.py", line 201, in <module>
detect()
File "C:\yolov7-gpu\detect.py", line 97, in detect
pred = non_max_suppression(pred, opt.conf_thres, opt.iou_thres, classes=opt.classes, agnostic=opt.agnostic_nms)
File "C:\yolov7-gpu\utils\general.py", line 713, in non_max_suppression
i = torchvision.ops.nms(boxes, scores, iou_thres) # NMS
File "C:\Users\aleja\anaconda3\envs\yolov7-gpu-env\lib\site-packages\torchvision\ops\boxes.py", line 41, in nms
return torch.ops.torchvision.nms(boxes, scores, iou_threshold)
File "C:\Users\aleja\anaconda3\envs\yolov7-gpu-env\lib\site-packages\torch\_ops.py", line 692, in __call__
return self._op(*args, **kwargs or {})
NotImplementedError: Could not run 'torchvision::nms' with arguments from the 'CUDA' backend. This could be because the operator doesn't exist for this backend, or was omitted during the selective/custom build process (if using custom build). If you are a Facebook employee using PyTorch on mobile, please visit https://fburl.com/ptmfixes for possible resolutions. 'torchvision::nms' is only available for these backends: [CPU, QuantizedCPU, BackendSelect, Python, FuncTorchDynamicLayerBackMode, Functionalize, Named, Conjugate, Negative, ZeroTensor, ADInplaceOrView, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, AutogradMPS, AutogradXPU, AutogradHPU, AutogradLazy, AutogradMeta, Tracer, AutocastCPU, AutocastCUDA, FuncTorchBatched, FuncTorchVmapMode, Batched, VmapMode, FuncTorchGradWrapper, PythonTLSSnapshot, FuncTorchDynamicLayerFrontMode, PreDispatch, PythonDispatcher].
字符串
安装cuda,cudnn,pythorch和要求,我不知道这是否是一些版本不兼容,但我已经检查了它,无论如何,任何想法,它可能是什么?
1条答案
按热度按时间628mspwn1#
你似乎没有安装正确的 Torch 后端。
基本上,由于Torch是如此高度优化,并且以非常专业的方式使用GPU,因此您需要为GPU安装正确版本的Torch,然后在代码中指定您安装的版本。
根据错误消息,您当前在代码中选择了
CUDA
后端,这是用于NVidia卡的。如果您确实有该品牌的卡,则没有正确安装torch。如果没有,您应该编辑指定CUDA
的代码段,然后再次Assert您已正确安装该卡的torch。要了解如何正确安装Torch,您应该查看here