Skip to content

Instantly share code, notes, and snippets.

@juliussin
Created November 9, 2020 03:12
Show Gist options
  • Save juliussin/76317f48a8da36422c396d84d0e6afd0 to your computer and use it in GitHub Desktop.
Save juliussin/76317f48a8da36422c396d84d0e6afd0 to your computer and use it in GitHub Desktop.
Check CUDA device and availability on PyTorch.
import torch
print('Torch CUDA Current Device: {}'.format(torch.cuda.current_device()))
print('Torch CUDA Device: {}'.format(torch.cuda.device(torch.cuda.current_device())))
print('Torch CUDA Device Count: {}'.format(torch.cuda.device_count()))
print('Torch CUDA Device Name: {}'.format(torch.cuda.get_device_name(torch.cuda.current_device())))
print('Torch CUDA Availability: {}'.format(torch.cuda.is_available()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment