Skip to content

Commit e917f05

Browse files
committed
Record CPU and GPU info in benchmarks output if available
1 parent f4e9458 commit e917f05

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

benchmarks/benchmarking.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,26 @@ def _get_version_or_none(package_name):
9191
return None
9292

9393

94+
def _get_cpu_info():
95+
"""Get details of CPU from cpuinfo if available or None if not."""
96+
try:
97+
import cpuinfo
98+
99+
return cpuinfo.get_cpu_info()
100+
except ImportError:
101+
return None
102+
103+
104+
def _get_gpu_info():
105+
"""Get details of GPU devices available from JAX or None if JAX not available."""
106+
try:
107+
import jax
108+
109+
return [d.device_kind for d in jax.devices() if d.platform == "gpu"]
110+
except ImportError:
111+
return None
112+
113+
94114
def skip(message):
95115
"""Skip benchmark for a particular parameter set with explanatory message.
96116
@@ -342,11 +362,14 @@ def parse_args_collect_and_run_benchmarks(module=None):
342362
"python_version": platform.python_version(),
343363
"release": platform.release(),
344364
"system": platform.system(),
365+
"cpu_info": _get_cpu_info(),
366+
"gpu_info": _get_gpu_info(),
345367
**package_versions,
346368
}
347369
with open(args.output_file, "w") as f:
348370
output = {
349371
"date_time": datetime.datetime.now().isoformat(),
372+
"benchmark_module": module.__name__,
350373
"system_info": system_info,
351374
"results": results,
352375
}

0 commit comments

Comments
 (0)