pytorch/cpuinfo
FreeCPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)
About pytorch/cpuinfo
cpuinfo is a C/C++ library for detecting CPU information essential for performance optimization. It provides cross-platform support for Linux, Windows, macOS, Android, iOS, and FreeBSD on x86, x86-64, ARM, and ARM64 architectures. The library detects supported instruction sets (up to AVX512 and ARMv8.3), SoC and core details (vendor, microarchitecture, core ID), cache hierarchy (type, size, line size, associativity, shared processors), and topology (logical processors, cores, packages). It includes workarounds for common hardware and OS bugs, supports heterogeneous cores (big.LITTLE, Max.Med.Min), and is thread-safe with no memory allocation after initialization and no exceptions. The library is well-tested with 60+ mock tests from real devices and is available under a permissive Simplified BSD license.
Key Features
Pros & Cons
- Comprehensive CPU feature detection in a single library
- Cross-platform and multi-architecture support
- Thread-safe with no dynamic memory allocation after init
- Robust with workarounds for common hardware/OS bugs
- Permissive BSD license allows commercial use
- Backed by PyTorch ecosystem and community
- Library is C/C++ only; no native bindings for other languages
- May require compilation and linking as a dependency
- Focuses only on CPU detection; does not cover GPU or other accelerators