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>
pull/3872/head
Glenn Jocher 1 year ago committed by GitHub
parent 965e405957
commit 793443a452
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      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):

Loading…
Cancel
Save