Different tensor indexing results on different machines

Hi, I have two different machines both Ubuntu 18.04 with torch 1.9.0 and 1.9.0+cu102. When I try the followings:

V = torch.tensor([[1,2,3],[4,5,6]])
idx = torch.tensor([0])

Now if I try:


I ll get different outputs:

tensor([[1, 2, 3]]) # for torch 1.9.0
tensor([1, 2, 3]) # for torch 1.9.0+cu102

Do you have any idea?

Assuming the difference between both installations would be a CPU-only vs. CUDA10.2 install, I cannot reproduce the issue and both pip wheels give tensor([[1, 2, 3]]) as the output using your code snippet.

@ptrblck this is very strange because the torch 1.9.0 is definitely using GPU.

Yes, that’s indeed strange, as I’ve installed the CPU and CUDA versions of 1.9.0 for this particular test and wasn’t able to reproduce it.

The problem is my own code which hooks torch and somehow affects the __getitem__ functionality of torch.