Error in functional.uniform_temporal_subsample when the input tensor has non-default device type
michaelnny opened this issue Β· comments
π Bugs / Unexpected behaviors
In the transforms.functional.uniform_temporal_subsample
, when the input tensor x
and the indices
do not have the same device type, the code will fail to run.
Possible causes is that we set some default device torch.set_default_device(device)
at global level, however our input tensor x
might have a different device, thus causing the issue.
return pytorchvideo.transforms.functional.uniform_temporal_subsample(
File "/home/michael/.local/lib/python3.10/site-packages/pytorchvideo/transforms/functional.py", line 41, in uniform_temporal_subsample
return torch.index_select(x, temporal_dim, indices)
File "/home/michael/.local/lib/python3.10/site-packages/torch/utils/_device.py", line 77, in __torch_function__
return func(*args, **kwargs)
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper_CUDA__index_select)
Instructions To Reproduce the Issue:
Please include the following (depending on what the issue is):
- Set default global level
torch.set_default_device('cuda')
- Use
load_and_transform_video_data
from ImageBind to process some video data https://github.com/facebookresearch/ImageBind/blob/c6a47d6dc2b53eced51d398c181d57049ca59286/imagebind/data.py#L287