Skip to content

Instantly share code, notes, and snippets.

@harisankarh
harisankarh / gpu_check.py
Created April 13, 2021 05:11
python program to check the status of gpus in a server
import os
if 'CUDA_VISIBLE_DEVICES' in os.environ:
print('CUDA_VISIBLE_DEVICES:', os.environ['CUDA_VISIBLE_DEVICES'])
if torch.cuda.is_available() is False:
print('no gpu available')
total_devices = torch.cuda.device_count()
print(f'{total_devices} gpus available')