rpg_e2vid
rpg_e2vid copied to clipboard
RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #3 'index' in call to _th_index_add_
When I run the code on GPU,I got the error blew:
Traceback (most recent call last):
File "run_reconstruction.py", line 107, in
device=device)
File "/home/wy/rpg_e2vid-master/utils/inference_utils.py", line 533, in events_to_voxel_grid_pytorch
source=vals_left[valid_indices])
RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #3 'index' in call to th_index_add
I find that the code is :
voxel_grid.index_add_(dim=0, index=xs[valid_indices] + ys[valid_indices] * width + tis_long[valid_indices] * width * height, source=vals_left[valid_indices])
thanks in advance.
Hello, Which version of PyTorch are you using? I seem to remember there was a slight API change in PyTorch that caused this issue in older versions.
facing the same error with torch==1.3.1
I am also facing with the same error with torch==1.4.0
Thanks for the feedback. I don't have access to a machine with a GPU to reproduce this now. Does the following change fix the error?
voxel_grid.index_add_(
dim=0,
index=(xs[valid_indices] + ys[valid_indices] * width + tis_long[valid_indices] * width * height).long(),
source=vals_left[valid_indices]
)
It runs on jetson tx2 with the change (torch version 1.3.0).
On Fri, Feb 14, 2020 at 1:28 PM supitalp [email protected] wrote:
Thanks for the feedback. I don't have access to a machine with a GPU to reproduce this now. Does the following change fix the error?
voxel_grid.index_add_( dim=0, index=(xs[valid_indices] + ys[valid_indices] * width + tis_long[valid_indices] * width * height).long(), source=vals_left[valid_indices] )
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/uzh-rpg/rpg_e2vid/issues/5?email_source=notifications&email_token=ADAJM2BDK2FG6HKON6ERNYDRC2E5RA5CNFSM4KBMOFQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELY3ZII#issuecomment-586267809, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADAJM2FNTY6SBGIOHVB5CRLRC2E5RANCNFSM4KBMOFQQ .
For GPU environment,
voxel_grid.index_add_(dim=0,
index=(xs[valid_indices] + ys[valid_indices]
* width + tis_long[valid_indices] * width * height).type(torch.cuda.LongTensor),
source=vals_left[valid_indices])
should fix this.
Also fixed in https://github.com/uzh-rpg/rpg_e2vid/pull/11