如何获取计算机中的硬件级线程数?

Cha*_*hna 3 command-line cpu

如何使用 ubuntu 终端获取计算机中的硬件级线程数?

Eri*_*lho 5

使用lscpu

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 69
Stepping:              1
CPU MHz:               806.347
BogoMIPS:              4988.30
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K
NUMA node0 CPU(s):     0-3
Run Code Online (Sandbox Code Playgroud)

操作系统将每个硬件线程识别为不同的 CPU。您想要的数字显示在第 行,这与乘以,和CPU(s):相同。Thread(s) per core:Core(s) per socket:Socket(s):

或者您可以使用单个命令:

lscpu -p | grep -c "^[0-9]"
Run Code Online (Sandbox Code Playgroud)