Skip to content

Instantly share code, notes, and snippets.

@shamsher31
Created June 4, 2024 11:19
Show Gist options
  • Save shamsher31/d444f45039904eec7648cddcb24da0c1 to your computer and use it in GitHub Desktop.
Save shamsher31/d444f45039904eec7648cddcb24da0c1 to your computer and use it in GitHub Desktop.
The simplest way to identify if you system has a dedicated GPU
# Install GPUtil
pip install gputil
# Create a Python script (e.g., check_gpu.py)
import GPUtil
try:
gpus = GPUtil.getAvailable(order='first', limit=8, maxLoad=0.5, maxMemory=0.5)
if gpus:
print('Nvidia GPU(s) detected!')
for gpu in gpus:
print(f'GPU {gpu}: {GPUtil.getGPUs()[gpu]}')
else:
print('No Nvidia GPUs available!')
except GPUtil.GPUtilError as err:
print(f"GPUtil Error: {err}")
# Run your script
python check_gpu.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment