简体   繁体   中英

python psutil get numbers of cpu sockets

it's possible to know numbers of sockets in my computer with python (and psutil ?)

for example with psutil i can to get numbers of core, but can i the number of sockets in mothercard ?

My computer have 2 sockets (and 2 xeon cpu)

psutils provides cpu_count function with parameters logical=True/False. logical=False returns the number of physical cores only.

psutil.cpu_count(logical=False)

psutil does not return this kind of information (as far as I could tell from the documentation and the source code).

If you are on Linux you can get the information in python with the following code:

import subprocess
cpu_sockets =  int(subprocess.check_output('cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l', shell=True))

Returns 1 on a single socket system (my Amazon server) and 2 on my Xeon workstation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM