1

as all know lscpu give the info about number of CORE and number of Thread

lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                48
On-line CPU(s) list:   0-47
Thread(s) per core:    2

I am searching about command that can give the total as

( number of CORE ) X ( number of Thread ) = 96

so output will be as case above = 96 CPU

we can do as

 CORE=` nproc --all `
 THREAD=`  lscpu | grep -i Thread | awk '{print $NF}' `

and

echo "$(( $CORE*$THREAD ))"

but this isn't elegant way

or maybe other elegant approach ?

we try also this ( but not get the total 96 cores's )

num_cpus=$(nproc)
# echo $num_cpus
48
  • Does your lscpu output not give a Core(s) per socket and Socket(s) line? – Stéphane Chazelas Aug 13 at 7:00
  • The CPU(s) line reports the number of "logical" CPUs, so number of threads. I'd expect your system has 24 cores, probably 2 sockets of 12 cores each. – Stéphane Chazelas Aug 13 at 7:05
0

Both nproc and the CPU(s) row in lscpu are the total number of threads.

So all you need to get the total number of threads is:

num_cpus=$(nproc)
  • nproc give only 48 and not 96!! so this isn't answer that I accepted – yael Aug 13 at 4:56
  • @yael, on my system, nproc also reports the number of threads. I would expect your system has 24 cores, 48 threads. Probably 2 x 12 core CPUs. – Stéphane Chazelas Aug 13 at 7:02
  • you can see from my question - CPU = 48 and Thread = 2 , so its 96 – yael Aug 13 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.