Created
October 29, 2020 08:53
-
-
Save ThoenigAdrian/b3b8f97a8aca88a9348d75e858d5cffc 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
# https://stackoverflow.com/a/53374933/5130800 | |
import torch | |
# 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 | |
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_cached(0)/1024**3,1), 'GB') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment