How to know the number of CPU in your machine

The relationship of several concepts:

Number(logical CPU) = Number(physical CPU) * Number(cores per physical CPU) * Number(Threads per core)

For Linux

  1. Get from the file /proc/cpuinfo
    Number of Physical CPU:

    cat /proc/cpuinfo | grep “physical id” | sort | uniq | wc -l

    Number of Cores per Physical CPU:

    cat /proc/cpuinfo | grep “cpu cores” | uniq

    Number of Logical CPU:

    cat /proc/cpuinfo | grep “processor” | wc -l

    Number of Threads per Core:

    Number(logical CPU) / Number(physical CPU) / Number(cores per physical CPU)

    Sample: 2 physical cpu, 8 cores per physical cpu, 32 logical cpu, 32/8/2=2 threads per core在这里插入图片描述

  2. Use command “lscpu”

    CPU(s): number of logical CPU
    Thread(s) per core:
    Core(s) per socket:
    CPU socket(s):
    L1d cache: Level 1 data cache
    L1I cache: Level 1 index cache
    L2 cache: Level 2 cache
    L3 cache: Level 3 cache

    Sample: 32 logic cpu, 2 threads per core, 8 cores per physical cpu, 2 physical cpu
    在这里插入图片描述

For Windows
Execute the commands:

cmd
wmic
cpu get *

Sample:
在这里插入图片描述
1 row: 1 physical cpu
NumberOfCores: 4 cores per physical cpu
NumberOfLogicalProcessors: 8 logical cpu
Number of thread per core: 8/4/1=2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值