gofortargets:

os.environ[“CUDA_VISIBLE_DEVICES”] = “1”


It looks like it’s always using “cuda:0” nonetheless.

Supposedly, b must be tensor([[ 2, 573, 2119, 1, 1, 0, 1441, 1, 2119, 2, 0, 0, 1, 0, 0]], device=‘cuda:0’). But somehow, sometimes b becomes tensor([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], device=‘cuda:0’).

Can you try it without that line (`os.environ[“CUDA_VISIBLE_DEVICES”] = “1”) and see if it works normally then? I have actually never used that except when I was using TensorFlow and I am not sure if this plays well with PyTorch.
You can do either
b = torch.tensor(arr, dtype=torch.int64, device=‘cuda:1’)
or
b = torch.tensor(arr, dtype=torch.int64, device=‘cuda:0’)
depending on which GPU you want to use.