From 793443a452790317ea9bf35c221b236de8eb1a7a Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 23 Jul 2023 14:14:57 +0200 Subject: [PATCH] Fix `get_cpu_info()` bug on Raspberry Pi (#3899) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- ultralytics/utils/torch_utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ultralytics/utils/torch_utils.py b/ultralytics/utils/torch_utils.py index 77235ae..cd82d52 100644 --- a/ultralytics/utils/torch_utils.py +++ b/ultralytics/utils/torch_utils.py @@ -1,5 +1,4 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license - import math import os import platform @@ -57,7 +56,11 @@ def get_cpu_info(): """Return a string with system CPU information, i.e. 'Apple M2'.""" check_requirements('py-cpuinfo') import cpuinfo # noqa - return cpuinfo.get_cpu_info()['brand_raw'].replace('(R)', '').replace('CPU ', '').replace('@ ', '') + + k = 'brand_raw', 'hardware_raw', 'arch_string_raw' # info keys sorted by preference (not all keys always available) + info = cpuinfo.get_cpu_info() # info dict + string = info.get(k[0] if k[0] in info else k[1] if k[1] in info else k[2], 'unknown') + return string.replace('(R)', '').replace('CPU ', '').replace('@ ', '') def select_device(device='', batch=0, newline=False, verbose=True):