How do you find out the number of CPU cores available in your Linux system? Here are a number of way, pick the one which works for you –
1. nproc command –
1 2 | [daniel@kauai tmp]$ nproc 2 |
2. /proc/cpuinfo
1 2 3 | [daniel@kauai tmp]$ grep proc /proc/cpuinfo processor : 0 processor : 1 |
3. top – run top command and press ‘1’ (number 1), you will see the list of cores at the top, right below tasks.
Cpu0 : 0.7%us, 0.3%sy, 0.0%ni, 99.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Cpu1 : 2.7%us, 1.0%sy, 0.0%ni, 96.3%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
4. lscpu – display information about the CPU architecture. Count Sockets times Core(s) per socket, in this case 2 x 1=2 –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | [daniel@kauai tmp]$ lscpu Architecture: x86_64 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 NUMA node(s): 1 Vendor ID: AuthenticAMD CPU family: 16 Model: 6 Model name: AMD Athlon(tm) II X2 250 Processor Stepping: 3 CPU MHz: 3000.000 BogoMIPS: 6027.19 Virtualization: AMD-V L1d cache: 64K L1i cache: 64K L2 cache: 1024K NUMA node0 CPU(s): 0,1 |
5. Kernel threads – pick one of the kernel house keeping threads, such as “migration” or “watchdog” and see on how many cores it is running –
1 2 3 4 5 6 7 | [daniel@kauai tmp]$ ps aux | grep '[m]igration' root 3 0.0 0.0 0 0 ? S Dec09 0:02 [migration /0 ] root 7 0.0 0.0 0 0 ? S Dec09 0:02 [migration /1 ] [daniel@kauai tmp]$ ps aux | grep '[w]atchdog' root 6 0.0 0.0 0 0 ? S Dec09 0:00 [watchdog /0 ] root 10 0.0 0.0 0 0 ? S Dec09 0:00 [watchdog /1 ] |