-
Notifications
You must be signed in to change notification settings - Fork 331
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
Summarize the bug "Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!" #510
Comments
Same here, Open3D, Python and System information
$ python3 vis_pred.py Using the Open3D PyTorch ops with CUDA 11 may have stability issues! We recommend to compile PyTorch from source with compile flags or use the PyTorch wheels at Ignore this message if PyTorch has been compiled with the aforementioned See isl-org/Open3D#3324 and INFO - 2022-04-26 23:32:03,045 - semantic_segmentation - Loading checkpoint /home/x/work/Open3D-ML/examples/vis_weights_RandLANet.pth |
I can see the bug in metric = SemSegMetric()
valid_scores, valid_labels = filter_valid_label(
torch.tensor(inference_result['predict_scores']).to(device),
torch.tensor(data['label']), model.cfg.num_classes,
model.cfg.ignored_label_inds, device)
metric.update(valid_scores, valid_labels)
log.info(f"Accuracy : {metric.acc()}")
log.info(f"IoU : {metric.iou()}") which can see in #435 |
We have had this error while training PointTransformer on a CustomDataset. We managed to fix this, by changing run_inference in semantic_segmentation.py. We changed line 161, to replicate what is going on in run_test(), ie: if hasattr(inputs['data'], 'to'):
inputs['data'].to(device) before results = model(inputs['data']) |
Thank you @RuiMargarido this worked for me! |
Checklist
master
branch).Describe the issue
Steps to reproduce the bug
Error message
/home/ub/anaconda3/envs/Genv3D/bin/python home/ub/Downloads/Open3D-ML-master/examples/vis_pred.py
INFO - 2022-04-07 14:08:39,636 - semantic_segmentation - Loading checkpoint /home/ljian/Downloads/Open3D-ML-master/examples/vis_weights_RandLANet.pth
INFO - 2022-04-07 14:08:41,694 - semantic_segmentation - Loading checkpoint /home/ljian/Downloads/Open3D-ML-master/examples/vis_weights_KPFCNN.pth
test 0/1: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍| 78416/78726 [00:02<00:00, 33596.46it/s]Traceback (most recent call last):
File "/home/ub/Downloads/Open3D-ML-master/examples/vis_pred.py", line 163, in
main()
File "/home/ub/Downloads/Open3D-ML-master/examples/vis_pred.py", line 151, in main
pcs_with_pred = pred_custom_data(pc_names, pcs, pipeline_r, pipeline_k)
File "/home/ub/Downloads/Open3D-ML-master/examples/vis_pred.py", line 40, in pred_custom_data
results_r = pipeline_r.run_inference(data)
File "/home/ub/anaconda3/envs/Genv3D/lib/python3.8/site-packages/open3d/_ml3d/torch/pipelines/semantic_segmentation.py", line 172, in run_inference
valid_scores, valid_labels = filter_valid_label(
File "/home/ub/anaconda3/envs/Genv3D/lib/python3.8/site-packages/open3d/_ml3d/torch/modules/losses/semseg_loss.py", line 19, in filter_valid_label
valid_scores = torch.gather(valid_scores, 0,
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
No response
Expected behavior
No response
Open3D, Python and System information
Additional information
No response
The text was updated successfully, but these errors were encountered: