Skip to content

Commit 9486425

Browse files
authored
Fix emrun.test_emrun_info on Apple Silicon macOS (#26821)
1 parent 5639320 commit 9486425

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

emrun.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,11 @@ def get_cpu_info():
774774
cpu_name = check_output(['sysctl', '-n', 'machdep.cpu.brand_string']).strip()
775775
physical_cores = int(check_output(['sysctl', '-n', 'machdep.cpu.core_count']).strip())
776776
logical_cores = int(check_output(['sysctl', '-n', 'machdep.cpu.thread_count']).strip())
777-
frequency = int(check_output(['sysctl', '-n', 'hw.cpufrequency']).strip()) // 1000000
777+
frequency = check_output(['sysctl', '-n', 'hw.cpufrequency']).strip()
778+
if not frequency:
779+
# Apple Silicon macOS devices have hw.tbfrequency instead of hw.cpufrequency
780+
frequency = check_output(['sysctl', '-n', 'hw.tbfrequency']).strip()
781+
frequency = int(frequency) // 1000000
778782
elif LINUX:
779783
for line in open('/proc/cpuinfo', encoding='utf-8').readlines():
780784
if 'model name' in line:
@@ -917,12 +921,15 @@ def macos_get_gpu_info():
917921
info = info.split("Chipset Model:")[1:]
918922
for gpu in info:
919923
model_name = gpu.split('\n')[0].strip()
920-
bus = re.search("Bus: (.*)", gpu).group(1).strip()
921-
memory = int(re.search("VRAM (.*?): (.*) MB", gpu).group(2).strip())
922-
gpus += [{'model': model_name + ' (' + bus + ')', 'ram': memory * 1024 * 1024}]
923-
return gpus
924+
if 'Bus' in gpu and 'VRAM' in gpu:
925+
bus = re.search("Bus: (.*)", gpu).group(1).strip()
926+
memory = int(re.search("VRAM (.*?): (.*) MB", gpu).group(2).strip())
927+
gpus += [{'model': model_name + ' (' + bus + ')', 'ram': memory * 1024 * 1024}]
928+
else:
929+
gpus += [{'model': model_name, 'ram': 0}]
924930
except Exception:
925931
pass
932+
return gpus
926933

927934

928935
def get_gpu_info():

0 commit comments

Comments
 (0)