Closed shawnl111 closed 7 months ago
probelm [(data["segment"] == ii + 1).sum() for ii in torch.arange(0, all_matches_origin[0].shape[0])[all_matches_origin[0] == indices0[0]]] RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)
in basicpbc_arch.py change
# area_accuracy = torch.tensor( # [(data["segment"] == ii + 1).sum() for ii in torch.arange(0, all_matches_origin[0].shape[0])[all_matches_origin[0] == indices0[0]]] # ).sum() / (weights.sum() * 1.0)
to indices_new = torch.arange(0, all_matches_origin[0].shape[0]).to(all_matches_origin[0].device) area_accuracy = torch.tensor([(data["segment"] == ii + 1).sum() for ii in indices_new[all_matches_origin[0] == indices0[0]]]).sum() / (weights.sum() * 1.0)
fixed it
torch.arange() will create tensors on CPU by default
Hi! Thank you for your feedback. torch version 1.12.1, cuda version 12.2, python version 3.9.12.
in basicpbc_arch.py change
# area_accuracy = torch.tensor( # [(data["segment"] == ii + 1).sum() for ii in torch.arange(0, all_matches_origin[0].shape[0])[all_matches_origin[0] == indices0[0]]] # ).sum() / (weights.sum() * 1.0)
to indices_new = torch.arange(0, all_matches_origin[0].shape[0]).to(all_matches_origin[0].device) area_accuracy = torch.tensor([(data["segment"] == ii + 1).sum() for ii in indices_new[all_matches_origin[0] == indices0[0]]]).sum() / (weights.sum() * 1.0)
fixed it
torch.arange() will create tensors on CPU by default
problem fixed. Thank you so much!
I'm training on torch2.2.1 and cuda11.8 on widows11