How to determine number of CPU sockets on a system
Environment
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 5
- Red Hat Enterprise Linux 4
Issue
- What command can be run to print the number of CPU sockets on a system?
Resolution
-
To accurately determine the number of CPU sockets on a system without physically opening and manually inspecting it, one must rely on the system's DMI table (populated by the BIOS). Install the dmidecode package (if necessary) and then run the following as root or via sudo:
dmidecode -t4 | grep Socket.Designation: | wc -lWarning: There have been cases where dmidecode reports incorrect results due to a problem in the firmware or bios. If you suspect that you are getting incorrect output from dmidecode, make sure to update your bios and other relevant firmware.
-
If all the CPU sockets on the system are filled (i.e., each socket has a processor in it), performing any of the following as a normal user will be sufficient:
-
Consult the
/proc/cpuinfofile, e.g.:grep physical.id /proc/cpuinfo | sort -u | wc -l -
RHEL6 and above: Use the
lscpucommand, e.g.:lscpu | grep -i "socket(s)" | wc -l -
RHEL6 and above: Use the
lstopocommand, provided by the hwloc package, e.g.:lstopo --whole-system --only Socket | wc -l
-
-
Related: How to find the number of physical cpus, cpu cores, and logical cpus
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.