Created
May 25, 2024 23:34
-
-
Save jgoodie/d6d434b814e17f14c262f999de2d382d to your computer and use it in GitHub Desktop.
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
# setting device on GPU if available, else CPU | |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') | |
print('Using device:', device) | |
print() | |
#Additional Info when using cuda | |
dev = 0 | |
if device.type == 'cuda': | |
print(torch.cuda.get_device_name(dev)) | |
print('Memory Usage:') | |
print('Allocated:', round(torch.cuda.memory_allocated(dev)/1024**3,1), 'GB') | |
print('Cached: ', round(torch.cuda.memory_reserved(dev)/1024**3,1), 'GB') | |
print("|=======================================|") | |
#Additional Info when using cuda | |
dev = 1 | |
if device.type == 'cuda': | |
print(torch.cuda.get_device_name(dev)) | |
print('Memory Usage:') | |
print('Allocated:', round(torch.cuda.memory_allocated(dev)/1024**3,1), 'GB') | |
print('Cached: ', round(torch.cuda.memory_reserved(dev)/1024**3,1), 'GB') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment