@@ -275,35 +275,31 @@ class GpuAmd(sensors.Gpu):
275
275
def stats () -> Tuple [float , float , float , float ]: # load (%) / used mem (%) / used mem (Mb) / temp (°C)
276
276
if pyamdgpuinfo :
277
277
# 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 )
283
279
284
280
try :
285
- memory_used_all = [ item .query_vram_usage () for item in amd_gpus ]
281
+ memory_used_all = amd_gpu .query_vram_usage ()
286
282
memory_used_bytes = sum (memory_used_all ) / len (memory_used_all )
287
283
memory_used = memory_used_bytes / 1000000
288
284
except :
289
285
memory_used_bytes = math .nan
290
286
memory_used = math .nan
291
287
292
288
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" ]
294
290
memory_total_bytes = sum (memory_total_all ) / len (memory_total_all )
295
291
memory_percentage = (memory_used_bytes / memory_total_bytes ) * 100
296
292
except :
297
293
memory_percentage = math .nan
298
294
299
295
try :
300
- load_all = [ item .query_load () for item in amd_gpus ]
296
+ load_all = amd_gpu .query_load ()
301
297
load = (sum (load_all ) / len (load_all )) * 100
302
298
except :
303
299
load = math .nan
304
300
305
301
try :
306
- temperature_all = [ item .query_temperature () for item in amd_gpus ]
302
+ temperature_all = amd_gpu .query_temperature ()
307
303
temperature = sum (temperature_all ) / len (temperature_all )
308
304
except :
309
305
temperature = math .nan
@@ -348,8 +344,9 @@ def fan_percent() -> float:
348
344
349
345
@staticmethod
350
346
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 )
353
350
354
351
@staticmethod
355
352
def is_available () -> bool :
0 commit comments