无法使用R中的所有核心

时间:2015-06-19 14:28:46

标签: r parallel-processing

我试图制作并行循环,但我发现R不能使用我的所有8个内核,它只使用1代码:

library(parallel)
library(foreach)
library(doParallel)
no_cores <- detectCores() - 1
cl <- makeCluster(no_cores)
registerDoParallel(cl, cores = no_cores)

sum.of.squares <- foreach(i = 1:10e4, .combine = "+", .init = 0) %dopar% {
  sqrt(i)
}

stopCluster(cl)

它仅占CPU的13-15%。为什么呢?

将Windows 8.1与R 3.2.1一起使用。

1 个答案:

答案 0 :(得分:1)

使用R Revolution Open(RRO)3.2

http://mran.revolutionanalytics.com/documents/rro/installation/

它与Intel MKL并行数学库集成。

查看fuller comparison here

相关问题