Skip to content

Instantly share code, notes, and snippets.

@elcolie
Created July 17, 2023 04:28
Show Gist options
  • Save elcolie/d5f732b43180f5d9d63185280f386287 to your computer and use it in GitHub Desktop.
Save elcolie/d5f732b43180f5d9d63185280f386287 to your computer and use it in GitHub Desktop.
Check CUDA GPU
import torch
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print('Using device:', device)
print()
#Additional Info when using cuda
if device.type == 'cuda':
print(torch.cuda.get_device_name(0))
print('Memory Usage:')
print('Allocated:', round(torch.cuda.memory_allocated(0)/1024**3,1), 'GB')
print('Cached: ', round(torch.cuda.memory_reserved(0)/1024**3,1), 'GB')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment