Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Miladiouss/f53969888a9e9e930fabf3edcda07609 to your computer and use it in GitHub Desktop.
Save Miladiouss/f53969888a9e9e930fabf3edcda07609 to your computer and use it in GitHub Desktop.
Ensure Python and PyTorch can detect all the GPUs in your system.
# GPU Detection Tests
from torch.cuda import device_count
import gpustat
print("""
If pytorch raises "RuntimeError: cuda runtime error (30)" after suspension,
run the following commands in linux terminal:
sudo rmmod nvidia_uvm
sudo rmmod nvidia
sudo modprobe nvidia
sudo modprobe nvidia_uvm
""")
print('gpustat output:')
gpustat.print_gpustat()
print('\nPyTorch detected {} GPUs.'.format(device_count()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment