cpuid
High-level Pythonic API for x86 CPU identification and feature detection
A user-friendly Python library that automatically identifies your CPU vendor, model, microarchitecture, and supported instruction sets. Built on top of cpuid-native for direct hardware access.
⚠️ x86/x64 ONLY: This library depends on the CPUID instruction which is exclusive to x86/x64 processors. It will NOT work on ARM processors (Apple Silicon M1/M2/M3, Raspberry Pi, AWS Graviton, etc.). Installation or execution on ARM will fail because the underlying
cpuid-nativeextension cannot be built on ARM architectures.
Features
- Automatic CPU identification - Detects Intel, AMD, and VIA processors
- Microarchitecture detection - Identifies specific CPU generations (Sandy Bridge, Haswell, Zen, etc.)
- Instruction set detection - Checks support for SSE, AVX, AVX2, BMI, and more
- Zero configuration - Just import and use
- Cross-platform - Linux, macOS, and Windows support
- Python 3.7+ - Full support through Python 3.13
Installation
pip install cpuid
Quick Start
import cpuid
# Get CPU vendor
vendor = cpuid.cpu_vendor()
print(f"Vendor: {vendor}") # e.g., "GenuineIntel" or "AuthenticAMD"
# Get CPU name/brand
name = cpuid.cpu_name()
print(f"CPU: {name}") # e.g., "Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz"
# Detect microarchitecture
arch, suffix = cpuid.cpu_microarchitecture()
print(f"Microarchitecture: {arch}{suffix}") # e.g., "kabylake" or "zen2"
# Check for specific instruction sets
eax, ebx, ecx, edx = cpuid.cpuid(1)
has_sse2 = bool(edx & (1 << 26))
has_avx = bool(ecx & (1 << 28))
print(f"SSE2: {has_sse2}, AVX: {has_avx}")
Real-World Example
import cpuid
def detect_cpu_capabilities():
"""Detect CPU and print comprehensive information."""
vendor = cpuid.cpu_vendor()
name = cpuid.cpu_name()
arch, suffix = cpuid.cpu_microarchitecture()
print("=" * 60)
print(f"Vendor: {vendor}")
print(f"Model: {name}")
print(f"Arch: {arch}{suffix}")
print("=" * 60)
# Check vector instruction support
_, _, ecx, edx = cpuid.cpuid(1)
features = {
"SSE": bool(edx & (1 << 25)),
"SSE2": bool(edx & (1 << 26)),
"SSE3": bool(ecx & (1 << 0)),
"SSSE3": bool(ecx & (1 << 9)),
"SSE4.1": bool(ecx & (1 << 19)),
"SSE4.2": bool(ecx & (1 << 20)),
"AVX": bool(ecx & (1 << 28)),
}
# Check AVX2 and BMI
_, ebx, _, _ = cpuid.cpuid_count(7, 0)
features["AVX2"] = bool(ebx & (1 << 5))
features["BMI1"] = bool(ebx & (1 << 3))
features["BMI2"] = bool(ebx & (1 << 8))
print("\nVector Instructions:")
for name, supported in features.items():
status = "✓" if supported else "✗"
print(f" {status} {name}")
if __name__ == "__main__":
detect_cpu_capabilities()
Output example:
============================================================
Vendor: GenuineIntel
Model: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Arch: kabylake
============================================================
Vector Instructions:
✓ SSE
✓ SSE2
✓ SSE3
✓ SSSE3
✓ SSE4.1
✓ SSE4.2
✓ AVX
✓ AVX2
✓ BMI1
✓ BMI2
API Reference
High-Level Functions
cpu_vendor() -> str
Returns the CPU vendor string (e.g., "GenuineIntel", "AuthenticAMD", "CentaurHauls").
cpu_name() -> str
Returns the full CPU brand string (e.g., "Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz").
cpu_microarchitecture() -> Tuple[str, str]
Returns a tuple of (architecture, suffix) where:
architecture: Detected microarchitecture (e.g.,"haswell","skylake","zen2")suffix: Additional flags like"noavx"if AVX is disabled
Intel architectures: pentium, pentium2, pentium3, pentium4, core2, nehalem, westmere, sandybridge, ivybridge, haswell, broadwell, skylake, kabylake, atom, silvermont, goldmont
AMD architectures: k5, k6, athlon, k8, k10, bobcat, bulldozer, piledriver, steamroller, excavator, jaguar
Low-Level Functions
cpuid(leaf: int) -> Tuple[int, int, int, int]
Executes CPUID instruction and returns (eax, ebx, ecx, edx) register values.
cpuid_count(leaf: int, subleaf: int) -> Tuple[int, int, int, int]
Executes CPUID with both leaf and subleaf, returns (eax, ebx, ecx, edx).
xgetbv(ctr: int) -> int
Reads extended control register (typically ctr=0 for XCR0).
Supported Architectures
Intel
- Legacy: Pentium, Pentium MMX, Pentium Pro, Pentium II/III/4, Pentium M
- Core: Core 2, Nehalem, Westmere, Sandy Bridge, Ivy Bridge
- Modern: Haswell, Broadwell, Skylake, Kaby Lake, Coffee Lake
- Low-power: Atom, Silvermont, Goldmont
- HPC: Knights Landing (Xeon Phi)
AMD
- Legacy: K5, K6, Athlon
- 64-bit: K8, K10
- Bulldozer family: Bulldozer, Piledriver, Steamroller, Excavator
- Modern: Bobcat, Jaguar, Zen (through microarchitecture detection)
VIA
- C3, C7, Nano
Use Cases
- Performance optimization - Select optimal algorithms based on CPU features
- System requirements - Check if CPU supports required instruction sets
- Benchmarking - Categorize results by CPU architecture
- Cross-platform development - Adapt code paths for different CPUs
- System monitoring - Display detailed CPU information
Low-Level Access
Need direct access to CPUID registers? Use cpuid-native:
import cpuid_native
success, eax, ebx, ecx, edx = cpuid_native.get_cpuid(1)
tsc, aux = cpuid_native.rdtscp()
xcr0 = cpuid_native.xgetbv(0)
Building from Source
git clone https://github.com/fpelliccioni/cpuid-py.git
cd cpuid-py
pip install -e .
License
MIT License - see LICENSE file for details.
Credits
Created and maintained by Fernando Pelliccioni
Metadata
Release files for cpuid 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cpuid-0.1.1.tar.gz | 9.2 kB | Without provenance | Details for cpuid-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cpuid-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for cpuid-0.1.1-py3-none-any.whl |
Total release size: 17.4 kB
Release files / cpuid-0.1.1.tar.gz
| Download URL | cpuid-0.1.1.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd5fd35fa29ede70de64235c38d0e824290606769b536a4fdf6c5951a989f38a
|
|
BLAKE2b-256 checksum How to use checksums |
515569e3eb791b409b5c251491516f4f87b27301c0646055bc4347668ed4ffbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / cpuid-0.1.1-py3-none-any.whl
| Download URL | cpuid-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b47e6d66bdd9f32edbeef918a9936d24a4ab102dd90a10992f218fdfe1fe00b4
|
|
BLAKE2b-256 checksum How to use checksums |
bf35fc1d0ffe657b3cb9424c18549950e5e1fdf612500d54091d9b29132d6368
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for cpuid 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.