@@ -94,7 +94,7 @@ def _read_apple_gpu_stats_and_cores() -> Tuple[float, float, int]:
94
94
(device_util, in_use_mem, gpu_core_count)
95
95
where:
96
96
- device_util is a fraction [0..1].
97
- - in_use_mem is in bytes .
97
+ - in_use_mem is in megabytes .
98
98
- gpu_core_count is an integer from top-level "gpu-core-count".
99
99
"""
100
100
matching_dict = IOServiceMatching (b"IOAccelerator" )
@@ -156,7 +156,7 @@ def _read_apple_gpu_stats_and_cores() -> Tuple[float, float, int]:
156
156
val_container_64 = ctypes .c_longlong (0 )
157
157
success = CFNumberGetValue (mem_val_ref , kCFNumberSInt64Type , ctypes .byref (val_container_64 ))
158
158
if success :
159
- in_use_mem = float (val_container_64 .value )
159
+ in_use_mem = float (val_container_64 .value ) / 1048576.0
160
160
161
161
IOObjectRelease (cf_key_util )
162
162
IOObjectRelease (cf_key_mem )
@@ -196,7 +196,7 @@ def get_num_cores(self) -> int:
196
196
return self .core_count
197
197
198
198
def get_stats (self ) -> Tuple [float , float ]:
199
- """Returns a tuple of (utilization%, memory in use in bytes )."""
199
+ """Returns a tuple of (utilization%, memory in use in megabytes )."""
200
200
if not self .has_gpu ():
201
201
return (0.0 , 0.0 )
202
202
try :
@@ -221,7 +221,7 @@ def _get_num_cores(self) -> int:
221
221
cores = gpu .get_num_cores ()
222
222
print (
223
223
f"GPU Utilization: { util * 100 :.1f} %, "
224
- f"In-Use GPU Memory: { mem } bytes , "
224
+ f"In-Use GPU Memory: { mem } megabytes , "
225
225
f"GPU Core Count: { cores } "
226
226
)
227
227
time .sleep (2 )
0 commit comments