@@ -173,14 +173,15 @@ def fan_percent(fan_name: str = None) -> float:
173
173
174
174
class Gpu (sensors .Gpu ):
175
175
@staticmethod
176
- def stats () -> Tuple [float , float , float , float ]: # load (%) / used mem (%) / used mem (Mb) / temp (°C)
176
+ def stats () -> Tuple [
177
+ float , float , float , float , float ]: # load (%) / used mem (%) / used mem (Mb) / total mem (Mb) / temp (°C)
177
178
global DETECTED_GPU
178
179
if DETECTED_GPU == GpuType .AMD :
179
180
return GpuAmd .stats ()
180
181
elif DETECTED_GPU == GpuType .NVIDIA :
181
182
return GpuNvidia .stats ()
182
183
else :
183
- return math .nan , math .nan , math .nan , math .nan
184
+ return math .nan , math .nan , math .nan , math .nan , math . nan
184
185
185
186
@staticmethod
186
187
def fps () -> int :
@@ -233,7 +234,8 @@ def is_available() -> bool:
233
234
234
235
class GpuNvidia (sensors .Gpu ):
235
236
@staticmethod
236
- def stats () -> Tuple [float , float , float , float ]: # load (%) / used mem (%) / used mem (Mb) / temp (°C)
237
+ def stats () -> Tuple [
238
+ float , float , float , float , float ]: # load (%) / used mem (%) / used mem (Mb) / total mem (Mb) / temp (°C)
237
239
# Unlike other sensors, Nvidia GPU with GPUtil pulls in all the stats at once
238
240
nvidia_gpus = GPUtil .getGPUs ()
239
241
@@ -246,6 +248,10 @@ def stats() -> Tuple[float, float, float, float]: # load (%) / used mem (%) / u
246
248
try :
247
249
memory_total_all = [item .memoryTotal for item in nvidia_gpus ]
248
250
memory_total_mb = sum (memory_total_all ) / len (memory_total_all )
251
+ except :
252
+ memory_total_mb = math .nan
253
+
254
+ try :
249
255
memory_percentage = (memory_used_mb / memory_total_mb ) * 100
250
256
except :
251
257
memory_percentage = math .nan
@@ -262,7 +268,7 @@ def stats() -> Tuple[float, float, float, float]: # load (%) / used mem (%) / u
262
268
except :
263
269
temperature = math .nan
264
270
265
- return load , memory_percentage , memory_used_mb , temperature
271
+ return load , memory_percentage , memory_used_mb , memory_total_mb , temperature
266
272
267
273
@staticmethod
268
274
def fps () -> int :
@@ -298,21 +304,28 @@ def is_available() -> bool:
298
304
299
305
class GpuAmd (sensors .Gpu ):
300
306
@staticmethod
301
- def stats () -> Tuple [float , float , float , float ]: # load (%) / used mem (%) / used mem (Mb) / temp (°C)
307
+ def stats () -> Tuple [
308
+ float , float , float , float , float ]: # load (%) / used mem (%) / used mem (Mb) / total mem (Mb) / temp (°C)
302
309
if pyamdgpuinfo :
303
310
# Unlike other sensors, AMD GPU with pyamdgpuinfo pulls in all the stats at once
304
311
pyamdgpuinfo .detect_gpus ()
305
312
amd_gpu = pyamdgpuinfo .get_gpu (0 )
306
313
307
314
try :
308
315
memory_used_bytes = amd_gpu .query_vram_usage ()
309
- memory_used = memory_used_bytes / 1000000
316
+ memory_used = memory_used_bytes / 1024 / 1024
310
317
except :
311
318
memory_used_bytes = math .nan
312
319
memory_used = math .nan
313
320
314
321
try :
315
322
memory_total_bytes = amd_gpu .memory_info ["vram_size" ]
323
+ memory_total = memory_total_bytes / 1024 / 1024
324
+ except :
325
+ memory_total_bytes = math .nan
326
+ memory_total = math .nan
327
+
328
+ try :
316
329
memory_percentage = (memory_used_bytes / memory_total_bytes ) * 100
317
330
except :
318
331
memory_percentage = math .nan
@@ -327,7 +340,7 @@ def stats() -> Tuple[float, float, float, float]: # load (%) / used mem (%) / u
327
340
except :
328
341
temperature = math .nan
329
342
330
- return load , memory_percentage , memory_used , temperature
343
+ return load , memory_percentage , memory_used , memory_total , temperature
331
344
elif pyadl :
332
345
amd_gpu = pyadl .ADLManager .getInstance ().getDevices ()[0 ]
333
346
@@ -341,8 +354,8 @@ def stats() -> Tuple[float, float, float, float]: # load (%) / used mem (%) / u
341
354
except :
342
355
temperature = math .nan
343
356
344
- # Memory absolute (M) and relative (%) usage not supported by pyadl
345
- return load , math .nan , math .nan , temperature
357
+ # GPU memory data not supported by pyadl
358
+ return load , math .nan , math .nan , math . nan , temperature
346
359
347
360
@staticmethod
348
361
def fps () -> int :
@@ -425,6 +438,7 @@ def virtual_free() -> int: # In bytes
425
438
except :
426
439
return - 1
427
440
441
+
428
442
class Disk (sensors .Disk ):
429
443
@staticmethod
430
444
def disk_usage_percent () -> float :
0 commit comments