R no longer runs in parallel

删除回忆录丶 提交于 2019-12-12 21:09:34

问题


I run (k)Ubuntu 12.04.2 and R 3.0.1

I wrote a bunch of code that used to run in parallel, but now it no longer does. Not even this runs in parallel any more:

library(doMC)
registerDoMC(4)
Results = foreach (i = 1:1e6, .combine = "c") %dopar% {
  sqrt(i)
}

And that definitely should. What I think broke it is either the R 3.0.1 update or a -dev, -devel BLAS package I installed. (openBLAS I think)

I've tried system(sprintf("taskset -p 0xffffffff %d", Sys.getpid())) as suggested elsewhere, and get this result:

pid 2415's current affinity mask: 1
pid 2415's new affinity mask: f

I've also tried running R with:

taskset 0xffff R

However after either of these steps running the loop still only uses one core.

I want parallel processing back! How can I get it?


回答1:


I found the solution! Ironically, to get parallel processing back I had to do both of the steps I mentioned in the Q at the same time

So, start R with

taskset 0xffff R

Then run

system(sprintf("taskset -p 0xffffffff %d", Sys.getpid()))

Within R.

Voila, parallel processing returns



来源:https://stackoverflow.com/questions/16789931/r-no-longer-runs-in-parallel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!