diff --git a/src/nnbench/context.py b/src/nnbench/context.py index 4ea8f27..8a563b8 100644 --- a/src/nnbench/context.py +++ b/src/nnbench/context.py @@ -172,13 +172,20 @@ def __call__(self) -> dict[str, Any]: result["system"] = platform.system() result["system-version"] = platform.release() - freq_struct = psutil.cpu_freq() - freq_conversion = self.conversion_table[self.frequnit[0]] - # result is in MHz, so we convert to Hz and apply the conversion factor. - result["frequency"] = freq_struct.current * 1e6 / freq_conversion + try: + # The CPU frequency is not available on some ARM devices + freq_struct = psutil.cpu_freq() + result["min_frequency"] = freq_struct.min + result["max_frequency"] = freq_struct.max + freq_conversion = self.conversion_table[self.frequnit[0]] + # result is in MHz, so we convert to Hz and apply the conversion factor. + result["frequency"] = freq_struct.current * 1e6 / freq_conversion + except RuntimeError: + result["frequency"] = 0 + result["min_frequency"] = 0 + result["max_frequency"] = 0 + result["frequency_unit"] = self.frequnit - result["min_frequency"] = freq_struct.min - result["max_frequency"] = freq_struct.max result["num_cpus"] = psutil.cpu_count(logical=False) result["num_logical_cpus"] = psutil.cpu_count() diff --git a/tests/test_context.py b/tests/test_context.py index f6847fe..5449497 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -38,7 +38,7 @@ def test_cpu_info_provider() -> None: # the popular CPU architectures. assert res["architecture"] != "" assert res["system"] != "" - assert res["frequency"] > 0 + assert res["frequency"] >= 0 assert res["num_cpus"] > 0 assert res["total_memory"] > 0