Created
October 5, 2023 19:54
-
-
Save frankwwu/16b81695a7bd4de225378c922cb47e3c to your computer and use it in GitHub Desktop.
GPU_info.py
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
# GPU information | |
import GPUtil | |
from tabulate import tabulate | |
print("="*40, "GPU Details", "="*40) | |
gpus = GPUtil.getGPUs() | |
list_gpus = [] | |
for gpu in gpus: | |
# get the GPU id | |
gpu_id = gpu.id | |
# name of GPU | |
gpu_name = gpu.name | |
# get % percentage of GPU usage of that GPU | |
gpu_load = f"{gpu.load*100}%" | |
# get free memory in MB format | |
gpu_free_memory = f"{gpu.memoryFree}MB" | |
# get used memory | |
gpu_used_memory = f"{gpu.memoryUsed}MB" | |
# get total memory | |
gpu_total_memory = f"{gpu.memoryTotal}MB" | |
# get GPU temperature in Celsius | |
gpu_temperature = f"{gpu.temperature} C" | |
gpu_uuid = gpu.uuid | |
list_gpus.append(( | |
gpu_id, gpu_name, gpu_load, gpu_free_memory, gpu_used_memory, | |
gpu_total_memory, gpu_temperature, gpu_uuid | |
)) | |
print(tabulate(list_gpus, headers=("id", "name", "load", "free memory", "used memory", "total memory", | |
"temperature", "uuid"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment