__init__.py 573 B

1234567891011121314
  1. import torch
  2. def print_device_info(device=None):
  3. # prints device stats. Code from https://stackoverflow.com/a/53374933/12891528
  4. device = torch.device(device or ('cuda' if torch.cuda.is_available() else 'cpu'))
  5. print('Using device:', device)
  6. # Additional Info when using cuda
  7. if device.type == 'cuda':
  8. print(torch.cuda.get_device_name(0))
  9. print('Memory Usage:')
  10. print('Allocated:', round(torch.cuda.memory_allocated(0) / 1024 ** 3, 1), 'GB')
  11. print('Cached: ', round(torch.cuda.memory_cached(0) / 1024 ** 3, 1), 'GB')