@@ -275,52 +275,42 @@ 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 ]
286
- memory_used_bytes = sum (memory_used_all ) / len (memory_used_all )
281
+ memory_used_bytes = amd_gpu .query_vram_usage ()
287
282
memory_used = memory_used_bytes / 1000000
288
283
except :
289
284
memory_used_bytes = math .nan
290
285
memory_used = math .nan
291
286
292
287
try :
293
- memory_total_all = [item .memory_info ["vram_size" ] for item in amd_gpus ]
294
- memory_total_bytes = sum (memory_total_all ) / len (memory_total_all )
288
+ memory_total_bytes = amd_gpu .memory_info ["vram_size" ]
295
289
memory_percentage = (memory_used_bytes / memory_total_bytes ) * 100
296
290
except :
297
291
memory_percentage = math .nan
298
292
299
293
try :
300
- load_all = [item .query_load () for item in amd_gpus ]
301
- load = (sum (load_all ) / len (load_all )) * 100
294
+ load = amd_gpu .query_load ()
302
295
except :
303
296
load = math .nan
304
297
305
298
try :
306
- temperature_all = [item .query_temperature () for item in amd_gpus ]
307
- temperature = sum (temperature_all ) / len (temperature_all )
299
+ temperature = amd_gpu .query_temperature ()
308
300
except :
309
301
temperature = math .nan
310
302
311
303
return load , memory_percentage , memory_used , temperature
312
304
elif pyadl :
313
- amd_gpus = pyadl .ADLManager .getInstance ().getDevices ()
305
+ amd_gpu = pyadl .ADLManager .getInstance ().getDevices ()[ 0 ]
314
306
315
307
try :
316
- load_all = [item .getCurrentUsage () for item in amd_gpus ]
317
- load = (sum (load_all ) / len (load_all ))
308
+ load = amd_gpu .getCurrentUsage ()
318
309
except :
319
310
load = math .nan
320
311
321
312
try :
322
- temperature_all = [item .getCurrentTemperature () for item in amd_gpus ]
323
- temperature = sum (temperature_all ) / len (temperature_all )
313
+ temperature = amd_gpu .getCurrentTemperature ()
324
314
except :
325
315
temperature = math .nan
326
316
@@ -348,8 +338,10 @@ def fan_percent() -> float:
348
338
349
339
@staticmethod
350
340
def frequency () -> float :
351
- # Not supported by Python libraries
352
- return math .nan
341
+ if pyamdgpuinfo :
342
+ return pyamdgpuinfo .get_gpu (0 ).query_sclk ()
343
+ elif pyadl :
344
+ return pyadl .ADLManager .getInstance ().getDevices ()[0 ].getCurrentEngineClock ()
353
345
354
346
@staticmethod
355
347
def is_available () -> bool :
0 commit comments