You could pass the device you want to train on as an argument to the script.
For example, ‘cuda:0’ corresponds to the 1st GPU in your system, ‘cuda:1’ corresponds to the 2nd GPU and so on.
Then assuming you store the passed argument in a variable named device, all you have to do is to call .to(device) on your tensors etc.