R不再并行运行 [英] R no longer runs in parallel

查看:113
本文介绍了R不再并行运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行(k)Ubuntu 12.04.2和R 3.0.1

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)
}

那绝对应该.我认为损坏的是R 3.0.1更新或我安装的-dev, -devel BLAS软件包. (我认为是openBLAS)

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)

我已经按照其他地方的建议尝试了system(sprintf("taskset -p 0xffffffff %d", Sys.getpid())),并得到了以下结果:

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

我还尝试过使用以下命令运行R:

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?

推荐答案

我找到了解决方案!具有讽刺意味的是,要恢复并行处理,我必须同时执行我在Q

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

所以,以R开头

taskset 0xffff R

然后运行

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

在R内

Voila,并行处理返回

Voila, parallel processing returns

这篇关于R不再并行运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆