简体   繁体   English

python psutil获取cpu套接字数

[英]python psutil get numbers of cpu sockets

it's possible to know numbers of sockets in my computer with python (and psutil ?) 使用python(和psutil?)可以知道计算机中的套接字数量

for example with psutil i can to get numbers of core, but can i the number of sockets in mothercard ? 例如,使用psutil,我可以获取核心数量,但是我可以在mothercard中获取套接字数量吗?

My computer have 2 sockets (and 2 xeon cpu) 我的电脑有2个插槽(和2个至强CPU)

psutils provides cpu_count function with parameters logical=True/False. psutils为cpu_count函数提供了逻辑= True / False参数。 logical=False returns the number of physical cores only. logical = False仅返回物理核的数量。

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). psutil不返回此类信息(据我从文档和源代码可以得知的那样)。

If you are on Linux you can get the information in python with the following code: 如果您使用的是Linux,则可以使用以下代码获取python中的信息:

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. 在单个套接字系统(我的Amazon服务器)上返回1,在我的Xeon工作站上返回2。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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