Skip to content

Commit 6b2a710

Browse files
committed
WIP
1 parent 181c954 commit 6b2a710

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

library/sensors/sensors_python.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -275,35 +275,31 @@ class GpuAmd(sensors.Gpu):
275275
def stats() -> Tuple[float, float, float, float]: # load (%) / used mem (%) / used mem (Mb) / temp (°C)
276276
if pyamdgpuinfo:
277277
# Unlike other sensors, AMD GPU with pyamdgpuinfo pulls in all the stats at once
278-
i = 0
279-
amd_gpus = []
280-
while i < pyamdgpuinfo.detect_gpus():
281-
amd_gpus.append(pyamdgpuinfo.get_gpu(i))
282-
i = i + 1
278+
amd_gpu = pyamdgpuinfo.get_gpu(0)
283279

284280
try:
285-
memory_used_all = [item.query_vram_usage() for item in amd_gpus]
281+
memory_used_all = amd_gpu.query_vram_usage()
286282
memory_used_bytes = sum(memory_used_all) / len(memory_used_all)
287283
memory_used = memory_used_bytes / 1000000
288284
except:
289285
memory_used_bytes = math.nan
290286
memory_used = math.nan
291287

292288
try:
293-
memory_total_all = [item.memory_info["vram_size"] for item in amd_gpus]
289+
memory_total_all = amd_gpu.memory_info["vram_size"]
294290
memory_total_bytes = sum(memory_total_all) / len(memory_total_all)
295291
memory_percentage = (memory_used_bytes / memory_total_bytes) * 100
296292
except:
297293
memory_percentage = math.nan
298294

299295
try:
300-
load_all = [item.query_load() for item in amd_gpus]
296+
load_all = amd_gpu.query_load()
301297
load = (sum(load_all) / len(load_all)) * 100
302298
except:
303299
load = math.nan
304300

305301
try:
306-
temperature_all = [item.query_temperature() for item in amd_gpus]
302+
temperature_all = amd_gpu.query_temperature()
307303
temperature = sum(temperature_all) / len(temperature_all)
308304
except:
309305
temperature = math.nan
@@ -348,8 +344,9 @@ def fan_percent() -> float:
348344

349345
@staticmethod
350346
def frequency() -> float:
351-
# Not supported by Python libraries
352-
return math.nan
347+
if pyamdgpuinfo:
348+
# Unlike other sensors, AMD GPU with pyamdgpuinfo pulls in all the stats at once
349+
return pyamdgpuinfo.get_gpu(0)
353350

354351
@staticmethod
355352
def is_available() -> bool:

0 commit comments

Comments
 (0)