Yes, I try to use it in script.
The goal is to automatically find a GPU with enough memory left.
import torch.cuda as cutorch

for i in range(cutorch.device_count()):
     if cutorch.getMemoryUsage(i) > MEM: 
         opts.gpuID = i
         break