-
Notifications
You must be signed in to change notification settings - Fork 571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: can't convert cuda:0 device type tensor to numpy #382
Comments
It can be fixed as follows:
def output_to_target(output, width, height):
|
In the last days I have been in the same problem, I did the same as you, but the disk crashed (Google Colab when trying to train Scaled YOLOv4). Do you know how can I fix it? |
I fixed it by using a smaller batch size |
I have faced the same error and fixed it using .cpu().numpy(). However, theere are some issues with the detections. I can see the first detections as nan type. There are no detected bounding box while inferencing. The same issue is not present with CPU inference. If anyone found the solution, please advise. |
Sistematic error. Platform Ubuntu.
Cuda downgraded to 10.2
torch downgraded to 10.0 and torchview downgraded to match
└─$ python test.py --img 896 --conf 0.001 --batch 8 --device 0 --data coco.yaml --weights weights/yolov4-p5.pt
Namespace(weights=['weights/yolov4-p5.pt'], data='./data/coco.yaml', batch_size=8, img_size=896, conf_thres=0.001, iou_thres=0.65, save_json=True, task='val', device='0', single_cls=False, augment=False, merge=False, verbose=False, save_txt=False)
Using CUDA device0 _CudaDeviceProperties(name='NVIDIA GeForce GTX 1060', total_memory=6078MB)
Fusing layers... Model Summary: 331 layers, 7.07943e+07 parameters, 6.81919e+07 gradients
/home/cdab63/.local/lib/python3.9/site-packages/torch/functional.py:445: 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:2157.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
Scanning labels ../coco/val2017.cache (0 found, 0 missing, 5000 empty, 0 duplicate, for 5000 images): 100%|████████████| 5000/5000 [00:00<00:00, 777904.22it/s]
WARNING: No labels found in ../coco/val2017/. See
Traceback (most recent call last):
File "/home/cdab63/Desenvolvimento/Deep-Learning/ScaledYOLOv4/test.py", line 269, in test(opt.data,
File "/home/cdab63/Desenvolvimento/Deep-Learning/ScaledYOLOv4/test.py", line 189, in test
plot_images(img, output_to_target(output, width, height), paths, str(f), names) # predictions
File "/home/cdab63/Desenvolvimento/Deep-Learning/ScaledYOLOv4/utils/general.py", line 1103, in output_to_target
return np.array(targets)
File "/home/cdab63/.local/lib/python3.9/site-packages/torch/_tensor.py", line 678, in array
return self.numpy()
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
The text was updated successfully, but these errors were encountered: