Reference for ultralytics/utils/cpu.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/cpu.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.utils.cpu.CPUInfo
Provide cross-platform CPU brand and model information.
Query platform-specific sources to retrieve a human-readable CPU descriptor and normalize it for consistent presentation across macOS, Linux, and Windows. If platform-specific probing fails, generic platform identifiers are used to ensure a stable string is always returned.
Methods:
Name | Description |
---|---|
name |
Return the normalized CPU name using platform-specific sources with robust fallbacks. |
_clean |
Normalize and prettify common vendor brand strings and frequency patterns. |
__str__ |
Return the normalized CPU name for string contexts. |
Examples:
>>> CPUInfo.name()
'Apple M4 Pro'
>>> str(CPUInfo())
'Intel Core i7-9750H 2.60GHz'
__str__
__str__() -> str
Return the normalized CPU name.
Source code in ultralytics/utils/cpu.py
84 85 86 |
|
name
staticmethod
name() -> str
Return a normalized CPU model string from platform-specific sources.
Source code in ultralytics/utils/cpu.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|