简体   繁体   English

编译R包时如何使用并行make?

[英]How to use parallel make when compiling R packages?

When using the make tool directly, one can use the -j option to build in parallel.直接使用make工具时,可以使用-j选项并行构建。

How can I use parallel build when installing an R package using install.packages() ?使用install.packages()安装 R 包时如何使用并行构建? make is invoked by R, not by me, so I can't pass the -j option to it. make由 R 调用,而不是由我调用,因此我无法将-j选项传递给它。 Setting export MAKE_FLAGS=-j4 before starting R did not work.在启动 R 之前设置export MAKE_FLAGS=-j4不起作用。 I am looking to set up parallel build permanently for my R installation.我希望为我的 R 安装永久设置并行构建。

The options(Ncpus=8) route is one way. options(Ncpus=8)路线是一种方式。 In install.packages() you have Ncpus = getOption("Ncpus") and that option is described asinstall.packages()你有Ncpus = getOption("Ncpus")并且该选项被描述为

Ncpus: the number of parallel processes to use for a parallel install of more than one source package. Ncpus:用于并行安装多个源包的并行进程数。 Values greater than one are supported if the 'make' command specified by 'Sys.getenv("MAKE", "make")' accepts argument '-k -j Ncpus'.如果 'Sys.getenv("MAKE", "make")' 指定的 'make' 命令接受参数 '-k -j Ncpus',则支持大于 1 的值。

I don't see it listed in update.packages() but it functions that same way on my Linux machines so builds generally happen in parallel.我没有在update.packages()中看到它,但它在我的 Linux 机器上以相同的方式运行,因此构建通常是并行发生的。

In short, this uses parallel builds of multiple packages, as opposed to make -j ... when just building one package.简而言之,这使用多个包的并行构建,而不是make -j ...仅构建一个包时。 I tried that route too but found the gains less compelling.我也尝试了这条路线,但发现收益不那么引人注目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM