Skip to content

Conversation

ntw-au
Copy link
Contributor

@ntw-au ntw-au commented Mar 29, 2022

This avoids a crash when calculating semantic segmentation loss during SemanticSegmentation.run_inference caused by the valid_scores and valid_labels tensors existing on separate devices.

This situation only arises when device is set to an accelerator, which makes valid_scores located on cpu and valid_labels located on cuda:0.

INFO - 2022-03-24 14:48:07,015 - train_evaluate - Launching inference for test[0]
Traceback (most recent call last):
  File "train_evaluate.py", line 157, in <module>
    result = pipeline.run_inference(test_instance)
  File "/opt/conda/lib/python3.6/site-packages/open3d/_ml3d/torch/pipelines/semantic_segmentation.py", line 175, in run_inference
    model.cfg.ignored_label_inds, device)
  File "/opt/conda/lib/python3.6/site-packages/open3d/_ml3d/torch/modules/losses/semseg_loss.py", line 20, in filter_valid_label
    valid_idx.unsqueeze(-1).expand(-1, num_classes))
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

This change is Reviewable

@sanskar107 sanskar107 self-requested a review April 7, 2022 14:34
@sanskar107 sanskar107 merged commit c8b8e1b into isl-org:dev Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants