Created
July 17, 2023 04:28
-
-
Save elcolie/d5f732b43180f5d9d63185280f386287 to your computer and use it in GitHub Desktop.
Check CUDA GPU
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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