Skip to content

Instantly share code, notes, and snippets.

View s-mawjee's full-sized avatar

Shahil Mawjee s-mawjee

  • South Africa
View GitHub Profile
@s-mawjee
s-mawjee / check_gpu.py
Last active May 20, 2024 17:35
Get Nvidia GPU information via python code, instead of watching nvidia-smi in the terminal. Useful when training ML models, can be added to the training loop.
import nvidia_smi
_GPU = False
_NUMBER_OF_GPU = 0
def _check_gpu():
global _GPU
global _NUMBER_OF_GPU
nvidia_smi.nvmlInit()
_NUMBER_OF_GPU = nvidia_smi.nvmlDeviceGetCount()