How to know on which GPU the tensor is?

I’m not completely sure, but I think a torch.cuda.*Tensor will have a get_device method.
As far as I remember, CPU tensors won’t have such a method, so you should check, if the tensor is on the GPU (or if the method exists) first.