在Windows 7-package doSMP上使用64位R进行并行处理

时间:2010-11-27 04:41:19

标签: r parallel-processing revolution-r

我已经在Windows 7上安装了R(64位)版本2.11.1,并且还从“REvolution foreach windows bundle”打包了doSMP和revoIPC以进行并行处理。然后我将库doSMP上传到R并从R

获得以下消息
> library(doSMP)
Loading required package: revoIPC
Error: package 'revoIPC' is not installed for 'arch=x64'

如何解决这个问题?似乎doSMP工作在R的32位分布上,而不是64位分布。

我还测试了以下程序

------------------------------------------------------
require(doSMP)
workers <- startWorkers(4) # My computer has 2 cores
registerDoSMP(workers)

# create a function to run in each itteration of the loop
check <-function(n) {
 for(i in 1:1000)
 {
  sme <- matrix(rnorm(100), 10,10)
  solve(sme)
 }
}


times <- 10 # times to run the loop

# comparing the running time for each loop
system.time(x <- foreach(j=1:times ) %dopar% check(j))  #  2.56 seconds  (notice that the first run would be slower, because of R's lazy loading)
system.time(for(j in 1:times ) x <- check(j))  #  4.82 seconds

# stop workers
---------------------------------------------------------------------------

我从R

收到以下消息
> workers <- startWorkers(4) # My computer has 2 cores
Error: could not find function "startWorkers"
> registerDoSMP(workers)
Error: could not find function "registerDoSMP"

非常感谢你的帮助。

Tony

3 个答案:

答案 0 :(得分:1)

错误消息

Loading required package: revoIPC
Error: package 'revoIPC' is not installed for 'arch=x64'

非常明确:您运行的是64位R,但是您没有加载doSMP所需的所有子组件,特别是缺少包revoIPC

如果您是Revo客户,请与他们联系。如果没有,那么您可能需要考虑R的不同并行计算解决方案。

答案 1 :(得分:1)

这是很久以前修复的,并且在最新的64位版本的Revolution R v6.1中运行良好。

以下示例取自Parallel Multicore Processing with R (on Windows),在我的机器上运行良好,该机器在Windows 7 x64上运行Revolution R v6.1 x64。

require(doSMP)
workers <- startWorkers(2) # My computer has 2 cores
registerDoSMP(workers)

# create a function to run in each itteration of the loop
check <-function(n) {
    for(i in 1:1000)
    {
        sme <- matrix(rnorm(100), 10,10)
        solve(sme)
    }
}


times <- 10 # times to run the loop

# comparing the running time for each loop
system.time(x <- foreach(j=1:times ) %dopar% check(j))  #  2.56 seconds  (notice that the first run would be slower, because of R's lazy loading)
system.time(for(j in 1:times ) x <- check(j))  #  4.82 seconds

# stop workers
stopWorkers(workers)

请注意,程序包doSMP内置于Revolution R的核心版本中,因此您无需从CRAN安装它(因此,您不会在程序包列表中找到它)。您所要做的就是使用require(SMP)加载它。在类似的说明中,包parallel也已内置到v2.14.0以后的所有R版本中,并使用require(parallel)加载。

有关此示例的更重要说明,请参阅完整文章Parallel Multicore Processing with R (on Windows)

答案 2 :(得分:0)

在Revolution Start..All Programs..Revolution R..Documentation..foreach and iterators - User's Guide下的Revolution R安装文件夹中有一个很好的.pdf文档。该文档描述了在运行Windows时如何在R中并行化任务。以下是它涉及的主题:

Parallelizing Loops
1.1 Using foreach
1.2 Parallel Backends
1.2.1 Using the doMC parallel backend
1.2.2 Using the doParallel parallel backend 
1.2.3 The doSMP parallel backend
1.2.4 Getting information about the parallel backend 
1.3 Nesting Calls to foreach 
1.4 Using Iterators
1.4.1 Some Special Iterators
1.4.2 Writing Iterators