简体   繁体   English

无法使用R中的所有核心

[英]Can't use all cores in R

I was trying to make a parallel loop, but I've found R can't utilize all my 8 cores, it uses only 1 with this code: 我试图做一个并行循环,但是我发现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)

It uses only about 13-15% of CPU. 它仅使用大约13-15%的CPU。 Why? 为什么?

Using Windows 8.1 with R 3.2.1. 使用Windows 8.1和R 3.2.1。

Use R Revolution Open (RRO) 3.2 使用R Revolution Open(RRO)3.2

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

It comes integrated with the Intel MKL parallel math libraries. 它与Intel MKL并行数学库集成在一起。

See a fuller comparison here . 在这里查看更全面的比较

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

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