web-dev-qa-db-ja.com

仮想を含むCPUコアの数を見つける方法

コマンドラインを使用して、仮想コア(ハイパースレッディングコア)を含むCPUのコア数を調べるにはどうすればよいですか?

120
TellMeWhy

CPUの数を数えることはできません

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

出力:

2

コアの数を確認するには!

cat /proc/cpuinfo | grep 'core id'
core id         : 0
core id         : 1

または

 $ nproc
 2

または、lscpuはすべての出力を表示します。

lscpu

Architecture:          i686
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                2
On-line CPU(s) list:   0,1
Thread(s) per core:    1
Core(s) per socket:    2
Socket(s):             1
Vendor ID:             GenuineIntel
CPU family:            15
Model:                 4
Stepping:              7
CPU MHz:               2792.992
BogoMIPS:              5585.98
L1d cache:             16K
L2 cache:              1024K
177
Ramesh Chand

既存の回答に追加するには、/ proc/cpuinfoの「兄弟」行を見て、Intelのハイパースレッディングに関する情報を確認できます。以下の例は2ソケットマシンのものです。 CPUには6つのコアがありますが、12の「兄弟」があることがわかります。 Intel CPUでは、これはHyperThreadingが有効になっており、6つの物理コアがあることを意味します。

processor       : 23
vendor_id       : GenuineIntel
cpu family      : 6
model           : 62
model name      : Intel(R) Xeon(R) CPU E5-2430 v2 @ 2.50GHz
stepping        : 4
microcode       : 0x428
cpu MHz         : 1599.707
cache size      : 15360 KB
physical id     : 1
siblings        : 12
core id         : 5
cpu cores       : 6
apicid          : 43
initial apicid  : 43
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc Arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm ida arat xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms
bogomips        : 5005.20
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

dmidecodeは、Linuxシステムが実行されているハードウェアを判別するのにも役立ちます。

13
Gimps

/proc/cpuinfoには、仮想を含むコンピューターのすべてのCPUが含まれています。少しのgrepでカウントできます:

grep -Pc '^processor\t' /proc/cpuinfo
7
Oli

コア/スレッドをオフにしないと仮定すると、このコマンドはあなたの質問に答えます:

getconf _NPROCESSORS_ONLN
5
Ruslan

すべてのコアを表示するhtoptopのより洗練されたバージョン)をインストールすることもできます。

Sudo apt-get install htop

次に、開始します:htop

2
chovy

タイプ:

 lscpu |grep 'CPU(s)'

他のいくつかの行の中でこれを取得します:

CPU(s)                  4

CPUに応じて、4の代わりに1、2 ...を取得できます。これは、CPUのコア数です。

1