nproc - make -j [jobs]

nproc - make -j [jobs]

1. man nproc

yongqiang@DESKTOP-6LEDFIJ:~$ man nproc

2. nproc - print the number of processing units available

nproc [OPTION]...

Print the number of processing units available to the current process, which may be less than the number of online processors.
打印当前进程可用的处理单元数,该数量可能少于在线处理器的数量。

--all
print the number of installed processors

--ignore=N
if possible, exclude N processing units

--help
display this help and exit

--version
output version information and exit

exclude [ɪk'skluːd]:v. 不包括,不放在考虑之列,防止…进入,阻止…参加
yongqiang@DESKTOP-6LEDFIJ:~$ nproc
12
yongqiang@DESKTOP-6LEDFIJ:~$
yongqiang@DESKTOP-6LEDFIJ:~$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                12
On-line CPU(s) list:   0-11
Thread(s) per core:    2
Core(s) per socket:    6
Socket(s):             1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 158
Model name:            Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Stepping:              10
CPU MHz:               2208.000
CPU max MHz:           2208.0000
BogoMIPS:              4416.00
Virtualization:        VT-x
Hypervisor vendor:     vertical
Virtualization type:   full
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 pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave osxsave avx f16c rdrand
yongqiang@DESKTOP-6LEDFIJ:~$
(base) yongqiang@famu-sys:~$ nproc
32
(base) yongqiang@famu-sys:~$
(base) yongqiang@famu-sys:~$ lscpu
Architecture:          x86_64
CPU 运行模式:    32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                32
On-line CPU(s) list:   0-31
每个核的线程数:2
每个座的核数:  8
Socket(s):             2
NUMA 节点:         2
厂商 ID:           GenuineIntel
CPU 系列:          6
型号:              79
Model name:            Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
步进:              1
CPU MHz:             2100.024
CPU max MHz:           3000.0000
CPU min MHz:           1200.0000
BogoMIPS:              4200.04
虚拟化:           VT-x
L1d 缓存:          32K
L1i 缓存:          32K
L2 缓存:           256K
L3 缓存:           20480K
NUMA node0 CPU(s):     0-7,16-23
NUMA node1 CPU(s):     8-15,24-31
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 cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti retpoline intel_ppin intel_pt spec_ctrl tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a rdseed adx smap xsaveopt cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts
(base) yongqiang@famu-sys:~$

It’s worth mentioning that this number does not represent the number of physical CPUs. The output of nproc corresponds to the CPUs field in the output of the lscpu command.
值得一提的是,这个数字并不代表物理 CPUs 的数量。nproc 的输出与 lscpu 命令的输出中的 CPUs 字段相对应。

And CPUs in itself is nothing but:
CPU 本身就是:

Thread (s) per core * Core (s) per socket * Socket (s) = CPU (s)

So in our case that comes out to be 2 x 6 x 1, which is equal to 12.
So in our case that comes out to be 2 x 8 x 2, which is equal to 32.

3. make -j [jobs]

Start the compilation process:

make -j 8

Modify the -j flag according to your processor. If you do not know the number of cores your processor, you can find it by typing nproc.

(base) yongqiang@famu-sys:~$ nproc
32
(base) yongqiang@famu-sys:~$
yongqiang@DESKTOP-6LEDFIJ:~$ nproc
12
yongqiang@DESKTOP-6LEDFIJ:~$

The compilation may take several minutes or more, depending on your system configuration.
编译可能需要几分钟或更长时间,具体取决于您的系统配置。

4. man make

(base) yongqiang@famu-sys:~$ man make

5. make - GNU make utility to maintain groups of programs

-j [jobs], --jobs[=jobs]
Specifies the number of jobs (commands) to run simultaneously. If there is more than one -j option, the last one is effective. If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously.
指定要同时运行的作业 (命令) 数。如果有多个 -j 选项,则最后一个有效。如果给 -j 选项不带参数,make 将不会限制可以同时运行的作业数量。

6. Build

https://www.docs.opencv.org/4.2.0/d7/d9f/tutorial_linux_install.html
From build directory execute make, it is recommended to do this in several threads

make -j 7 # runs 7 jobs in parallel

7. make all -j $(($(nproc) + 1))

https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-Installation-Guide
Note that the build process can be sped up by appending -j $(($(nproc) + 1)) to the above commands, which distributes the build across the available processors on your system. For example:

make all

can become

make all -j $(($(nproc) + 1))

8. make -j $(($(nproc) + 1))

https://github.com/BVLC/caffe/wiki/OpenCV-3.3-Installation-Guide-on-Ubuntu-16.04

make -j $(($(nproc) + 1))

9. make -j4

Run make -j4 (the -j4 is optional, it just tells the compiler to build in 4 threads).

thread [θred]:n. 螺纹,线索,思路,脉络 v. 穿过,穿 (针),纫 (针),(使) 穿过
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值