PyTorch_YOLOv4 icon indicating copy to clipboard operation
PyTorch_YOLOv4 copied to clipboard

RuntimeError: Could not run 'torchvision::nms'

Open sonica1987 opened this issue 5 years ago • 5 comments

Epoch gpu_mem GIoU obj cls total targets img_size 4/99 3.91G 0.08337 0.4457 0 0.5291 258 192: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████| 19/19 [00:07<00:00, 2.69it/s] Class Images Targets P R [email protected] [email protected]:.95: 0%| | 0/2 [00:00<?, ?it/s] Traceback (most recent call last): File "train.py", line 438, in train(hyp, opt, device, tb_writer) File "train.py", line 308, in train save_dir=log_dir) File "/home/keroro/Downloads/PyTorch_YOLOv4-master/test.py", line 128, in test output = non_max_suppression(inf_out, conf_thres=conf_thres, iou_thres=iou_thres, merge=merge) File "/home/keroro/Downloads/PyTorch_YOLOv4-master/utils/general.py", line 619, in non_max_suppression i = torchvision.ops.boxes.nms(boxes, scores, iou_thres) File "/home/keroro/.local/lib/python3.6/site-packages/torchvision/ops/boxes.py", line 42, in nms return torch.ops.torchvision.nms(boxes, scores, iou_threshold) RuntimeError: Could not run 'torchvision::nms' with arguments from the 'CUDA' backend. 'torchvision::nms' is only available for these backends: [CPU, BackendSelect, Named, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, Tracer, Autocast, Batched, VmapMode].

CPU: registered at /root/project/torchvision/csrc/vision.cpp:59 [kernel] BackendSelect: fallthrough registered at /pytorch/aten/src/ATen/core/BackendSelectFallbackKernel.cpp:3 [backend fallback] Named: registered at /pytorch/aten/src/ATen/core/NamedRegistrations.cpp:7 [backend fallback] AutogradOther: fallthrough registered at /pytorch/aten/src/ATen/core/VariableFallbackKernel.cpp:35 [backend fallback] AutogradCPU: fallthrough registered at /pytorch/aten/src/ATen/core/VariableFallbackKernel.cpp:39 [backend fallback] AutogradCUDA: fallthrough registered at /pytorch/aten/src/ATen/core/VariableFallbackKernel.cpp:43 [backend fallback] AutogradXLA: fallthrough registered at /pytorch/aten/src/ATen/core/VariableFallbackKernel.cpp:47 [backend fallback] Tracer: fallthrough registered at /pytorch/torch/csrc/jit/frontend/tracer.cpp:967 [backend fallback] Autocast: fallthrough registered at /pytorch/aten/src/ATen/autocast_mode.cpp:254 [backend fallback] Batched: registered at /pytorch/aten/src/ATen/BatchingRegistrations.cpp:511 [backend fallback] VmapMode: fallthrough registered at /pytorch/aten/src/ATen/VmapModeRegistrations.cpp:33 [backend fallback]

sonica1987 avatar Nov 23 '20 23:11 sonica1987

same ploblem for me

runauto avatar Dec 02 '20 10:12 runauto

Epoch gpu_mem GIoU obj cls total targets img_size 4/99 3.91G 0.08337 0.4457 0 0.5291 258 192: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████| 19/19 [00:07<00:00, 2.69it/s] Class Images Targets P R [email protected] [email protected]:.95: 0%| | 0/2 [00:00<?, ?it/s] Traceback (most recent call last): File "train.py", line 438, in train(hyp, opt, device, tb_writer) File "train.py", line 308, in train save_dir=log_dir) File "/home/keroro/Downloads/PyTorch_YOLOv4-master/test.py", line 128, in test output = non_max_suppression(inf_out, conf_thres=conf_thres, iou_thres=iou_thres, merge=merge) File "/home/keroro/Downloads/PyTorch_YOLOv4-master/utils/general.py", line 619, in non_max_suppression i = torchvision.ops.boxes.nms(boxes, scores, iou_thres) File "/home/keroro/.local/lib/python3.6/site-packages/torchvision/ops/boxes.py", line 42, in nms return torch.ops.torchvision.nms(boxes, scores, iou_threshold) RuntimeError: Could not run 'torchvision::nms' with arguments from the 'CUDA' backend. 'torchvision::nms' is only available for these backends: [CPU, BackendSelect, Named, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, Tracer, Autocast, Batched, VmapMode].

CPU: registered at /root/project/torchvision/csrc/vision.cpp:59 [kernel] BackendSelect: fallthrough registered at /pytorch/aten/src/ATen/core/BackendSelectFallbackKernel.cpp:3 [backend fallback] Named: registered at /pytorch/aten/src/ATen/core/NamedRegistrations.cpp:7 [backend fallback] AutogradOther: fallthrough registered at /pytorch/aten/src/ATen/core/VariableFallbackKernel.cpp:35 [backend fallback] AutogradCPU: fallthrough registered at /pytorch/aten/src/ATen/core/VariableFallbackKernel.cpp:39 [backend fallback] AutogradCUDA: fallthrough registered at /pytorch/aten/src/ATen/core/VariableFallbackKernel.cpp:43 [backend fallback] AutogradXLA: fallthrough registered at /pytorch/aten/src/ATen/core/VariableFallbackKernel.cpp:47 [backend fallback] Tracer: fallthrough registered at /pytorch/torch/csrc/jit/frontend/tracer.cpp:967 [backend fallback] Autocast: fallthrough registered at /pytorch/aten/src/ATen/autocast_mode.cpp:254 [backend fallback] Batched: registered at /pytorch/aten/src/ATen/BatchingRegistrations.cpp:511 [backend fallback] VmapMode: fallthrough registered at /pytorch/aten/src/ATen/VmapModeRegistrations.cpp:33 [backend fallback]

change torchvision 0.8.1 is ok

runauto avatar Dec 03 '20 00:12 runauto

For me it's still doesn't work...

LucasColas avatar Jan 28 '21 10:01 LucasColas

change torchvision 0.8.1 is ok

@runauto , It's works for me. Thanks.

mheriyanto avatar Mar 30 '21 08:03 mheriyanto

I believe by default, if you build torchvision from source, it does not build with CUDA support.

The fix for me was to build torchvision with the -DWITH_CUDA=on flag as they mention in the build instructions.

Installation From source:

cd vision
mkdir build && cd build
cmake -DTorch_DIR=/path/to/Torch/ -DWITH_CUDA=on ..
make
make install

Additional information available in these two issues I created: https://github.com/zhiqwang/yolov5-rt-stack/issues/132, https://github.com/pytorch/vision/issues/4175

mattpopovich avatar Jul 14 '21 20:07 mattpopovich