@@ -173,14 +173,15 @@ def fan_percent(fan_name: str = None) -> float:
173173
174174class Gpu (sensors .Gpu ):
175175 @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)
177178 global DETECTED_GPU
178179 if DETECTED_GPU == GpuType .AMD :
179180 return GpuAmd .stats ()
180181 elif DETECTED_GPU == GpuType .NVIDIA :
181182 return GpuNvidia .stats ()
182183 else :
183- return math .nan , math .nan , math .nan , math .nan
184+ return math .nan , math .nan , math .nan , math .nan , math . nan
184185
185186 @staticmethod
186187 def fps () -> int :
@@ -233,7 +234,8 @@ def is_available() -> bool:
233234
234235class GpuNvidia (sensors .Gpu ):
235236 @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)
237239 # Unlike other sensors, Nvidia GPU with GPUtil pulls in all the stats at once
238240 nvidia_gpus = GPUtil .getGPUs ()
239241
@@ -246,6 +248,10 @@ def stats() -> Tuple[float, float, float, float]: # load (%) / used mem (%) / u
246248 try :
247249 memory_total_all = [item .memoryTotal for item in nvidia_gpus ]
248250 memory_total_mb = sum (memory_total_all ) / len (memory_total_all )
251+ except :
252+ memory_total_mb = math .nan
253+
254+ try :
249255 memory_percentage = (memory_used_mb / memory_total_mb ) * 100
250256 except :
251257 memory_percentage = math .nan
@@ -262,7 +268,7 @@ def stats() -> Tuple[float, float, float, float]: # load (%) / used mem (%) / u
262268 except :
263269 temperature = math .nan
264270
265- return load , memory_percentage , memory_used_mb , temperature
271+ return load , memory_percentage , memory_used_mb , memory_total_mb , temperature
266272
267273 @staticmethod
268274 def fps () -> int :
@@ -298,21 +304,28 @@ def is_available() -> bool:
298304
299305class GpuAmd (sensors .Gpu ):
300306 @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)
302309 if pyamdgpuinfo :
303310 # Unlike other sensors, AMD GPU with pyamdgpuinfo pulls in all the stats at once
304311 pyamdgpuinfo .detect_gpus ()
305312 amd_gpu = pyamdgpuinfo .get_gpu (0 )
306313
307314 try :
308315 memory_used_bytes = amd_gpu .query_vram_usage ()
309- memory_used = memory_used_bytes / 1000000
316+ memory_used = memory_used_bytes / 1024 / 1024
310317 except :
311318 memory_used_bytes = math .nan
312319 memory_used = math .nan
313320
314321 try :
315322 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 :
316329 memory_percentage = (memory_used_bytes / memory_total_bytes ) * 100
317330 except :
318331 memory_percentage = math .nan
@@ -327,7 +340,7 @@ def stats() -> Tuple[float, float, float, float]: # load (%) / used mem (%) / u
327340 except :
328341 temperature = math .nan
329342
330- return load , memory_percentage , memory_used , temperature
343+ return load , memory_percentage , memory_used , memory_total , temperature
331344 elif pyadl :
332345 amd_gpu = pyadl .ADLManager .getInstance ().getDevices ()[0 ]
333346
@@ -341,8 +354,8 @@ def stats() -> Tuple[float, float, float, float]: # load (%) / used mem (%) / u
341354 except :
342355 temperature = math .nan
343356
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
346359
347360 @staticmethod
348361 def fps () -> int :
@@ -425,6 +438,7 @@ def virtual_free() -> int: # In bytes
425438 except :
426439 return - 1
427440
441+
428442class Disk (sensors .Disk ):
429443 @staticmethod
430444 def disk_usage_percent () -> float :
0 commit comments