Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdb0b45c

Browse files
committed
edited get hardware/sys information tutorial
1 parent637fb0e commitdb0b45c

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

‎general/sys-info/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
psutil
1+
psutil
2+
tabulate
3+
gputil

‎general/sys-info/sys_info.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,32 @@ def get_size(bytes, suffix="B"):
108108
print(f"Total Bytes Received:{get_size(net_io.bytes_recv)}")
109109

110110

111+
# GPU information
112+
importGPUtil
113+
fromtabulateimporttabulate
114+
print("="*40,"GPU Details","="*40)
115+
gpus=GPUtil.getGPUs()
116+
list_gpus= []
117+
forgpuingpus:
118+
# get the GPU id
119+
gpu_id=gpu.id
120+
# name of GPU
121+
gpu_name=gpu.name
122+
# get % percentage of GPU usage of that GPU
123+
gpu_load=f"{gpu.load*100}%"
124+
# get free memory in MB format
125+
gpu_free_memory=f"{gpu.memoryFree}MB"
126+
# get used memory
127+
gpu_used_memory=f"{gpu.memoryUsed}MB"
128+
# get total memory
129+
gpu_total_memory=f"{gpu.memoryTotal}MB"
130+
# get GPU temperature in Celsius
131+
gpu_temperature=f"{gpu.temperature} °C"
132+
gpu_uuid=gpu.uuid
133+
list_gpus.append((
134+
gpu_id,gpu_name,gpu_load,gpu_free_memory,gpu_used_memory,
135+
gpu_total_memory,gpu_temperature,gpu_uuid
136+
))
137+
138+
print(tabulate(list_gpus,headers=("id","name","load","free memory","used memory","total memory",
139+
"temperature","uuid")))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp