Skip to main content

Get CPU info with pure Python 2 & 3

Project description

Py-cpuinfo gets CPU info with pure Python. Py-cpuinfo should work without any extra programs or libraries, beyond what your OS provides. It does not require any compilation(C/C++, assembly, et cetera) to use. It works on Linux, OS X, Windows, BSD, Solaris, Cygwin, Haiku, and BeagleBone. It currently only works on X86 and some ARM CPUs.

These approaches are used for getting info:

  1. Windows Registry (Windows)

  2. /proc/cpuinfo (Linux)

  3. sysctl (OS X)

  4. dmesg (Unix/Linux)

  5. isainfo and kstat (Solaris)

  6. cpufreq-info (BeagleBone)

  7. lscpu (Unix/Linux)

  8. sysinfo (Haiku)

  9. Querying the CPUID register (Intel X86 CPUs)

Run as a script

$ python cpuinfo/cpuinfo.py
Vendor ID: GenuineIntel
Hardware Raw:
Brand: Intel(R) Core(TM) i5-4440 CPU @ 3.10GHz
Hz Advertised: 3.1000 GHz
Hz Actual: 3.0794 GHz
Hz Advertised Raw: (3100000000, 0)
Hz Actual Raw: (3079444000, 0)
Arch: X86_64
Bits: 64
Count: 4
Raw Arch String: x86_64
L2 Cache Size: 6144 KB
L2 Cache Line Size: 0
L2 Cache Associativity: 0
Stepping: 3
Model: 60
Family: 6
Processor Type: 0
Extended Model: 0
Extended Family: 0
Flags: apic, clflush, cmov, constant_tsc, cx8, de, fpu, fxsr, ht, lahf_lm,
lm, mca, mce, mmx, msr, mtrr, nopl, nx, pae, pat, pge, pni, pse, pse36,
rdtscp, rep_good, sep, sse, sse2, ssse3, syscall, tsc, vme

Run as a library

from cpuinfo import cpuinfo # from installed with pip
#import cpuinfo # from path

# Have the library pick the best method for getting your CPU info
info = cpuinfo.get_cpu_info()

# Or use /proc/cpuinfo
#info = cpuinfo.get_cpu_info_from_proc_cpuinfo()

# Or use the Windows registry
#info = cpuinfo.get_cpu_info_from_registry()

# Or use sysctl
#info = cpuinfo.get_cpu_info_from_sysctl()

# Or use CPU CPUID register
#info = cpuinfo.get_cpu_info_from_cpuid()

# Print some CPU values
print('Vendor ID: {0}'.format(info['vendor_id']))
print('Brand: {0}'.format(info['brand']))
print('Hz Advertised: {0}'.format(info['hz_advertised']))
print('Hz Actual: {0}'.format(info['hz_actual']))
print('Hz Advertised Raw: {0}'.format(info['hz_advertised_raw']))
print('Hz Actual Raw: {0}'.format(info['hz_actual_raw']))
print('Arch: {0}'.format(info['arch']))
print('Bits: {0}'.format(info['bits']))
print('Count: {0}'.format(info['count']))
print('Flags: {0}'.format(', '.join(info['flags'])))

Bugs and Corrections

Please report a Bug if you suspect any of this information is wrong.

If py-cpuinfo does not work on your machine, run the script:

python tools/get_system_info.py

and create bug report with the generated “system_info.txt” file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

py-cpuinfo-0.1.8.zip (18.8 kB view details)

Uploaded Source

py-cpuinfo-0.1.8.tar.gz (15.3 kB view details)

Uploaded Source

File details

Details for the file py-cpuinfo-0.1.8.zip.

File metadata

  • Download URL: py-cpuinfo-0.1.8.zip
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for py-cpuinfo-0.1.8.zip
Algorithm Hash digest
SHA256 4393b786c88dc403244245b5ee426bd50f71d5508b10ee2d3cb3c875eb2e6f5a
MD5 c1c15c8523aad361e7a2742bec8d5267
BLAKE2b-256 4f8b9e6f33c0c60bb77da2ecc0384be0c857083985349ae9fc3196be7b939a35

See more details on using hashes here.

File details

Details for the file py-cpuinfo-0.1.8.tar.gz.

File metadata

  • Download URL: py-cpuinfo-0.1.8.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for py-cpuinfo-0.1.8.tar.gz
Algorithm Hash digest
SHA256 892abe41eba777c2107c54703dde0c769965c3da79d100d94e4cd5e8a9ba3e59
MD5 351499ee26d44be1ec915a0bb30dc970
BLAKE2b-256 fe79f861cc5cbcb6cd53446cf29016ebd3abff9760357124dd18c71808e1a49e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page