Created
June 4, 2024 11:19
-
-
Save shamsher31/d444f45039904eec7648cddcb24da0c1 to your computer and use it in GitHub Desktop.
The simplest way to identify if you system has a dedicated GPU
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
# 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