插入符号中R的并行处理

Dhr*_*jan 8 parallel-processing r

在插入符号文档中给出了允许并行处理以下代码的工作原理

library(doMC) 
registerDoMC(cores = 5) 
## All subsequent models are then run in parallel
Run Code Online (Sandbox Code Playgroud)

但在最新的R版本(3.4)中,doMC包不可用.任何人都可以告诉我任何其他方式进行并行处理?

更新:罗马建议的工作原理.DoMC不适用于Windows.对于Windows使用doParallel包cls = makeCluster(no of cores to use)然后registerDoParallel(cls).还要确保在trControl中将allowParallel设置为TRUE.

Pab*_*mes 7

只是为了扩展前面答案的实现并基本上使用Caret 包文档,这里有一个适合我的食谱:

set.seed(112233)
library(parallel) 
# Calculate the number of cores
no_cores <- detectCores() - 1

library(doParallel)
# create the cluster for caret to use
cl <- makePSOCKcluster(no_cores)
registerDoParallel(cl)

# do your regular caret train calculation enabling
# allowParallel = TRUE for the functions that do
# use it as part of their implementation. This is
# determined by the caret package.

stopCluster(cl)
registerDoSEQ()
Run Code Online (Sandbox Code Playgroud)


Rom*_*rik 6

doMC利用程序包的功能multicore以分布式/并行模式进行计算。如果您使用的是受支持的平台(不是Windows),则可以。

您可以使用parallelR附带的另一个框架。为此,您需要doParallel在所有三个主要平台上都可以使用的软件包。