You could go with the following approach:
print("Outside device is 0")  # On device 0 (default in most scenarios)
with torch.cuda.device(1):
    print("Inside device is 1")  # On device 1
print("Outside device is still 0")  # On device 0

You could also use .cuda(GPU_NUMBER) at the end of the tensors, but the first option has been quicker and cleaner for me.