How to run python script on GPU in paperspace

Within my jupyter notebook, torch.cuda.is_available() returns True. But if I run a python script using !python xxx.py then the torch.cuda.is_available() inside that xxx.py returns False. So it looks like the script is not being run on GPU. How should I go about this?