【问题标题】:Parallel processing in R with 64-bit on Windows 7- package doSMP在 Windows 7 包 doSMP 上使用 64 位 R 进行并行处理
【发布时间】:2010-11-27 04:41:18
【问题描述】:

我已经在 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"

非常感谢您的帮助。

托尼

【问题讨论】:

    标签: r parallel-processing revolution-r


    【解决方案1】:

    错误信息

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

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

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

    【讨论】:

    • 谢谢德克。可能我会在带有 doMC 的 Linux 平台上尝试。我认为 doSMP 目前仅适用于 Windows 上的 32 位 R 吗?
    • 我刚刚使用降雪测试了一个与 cpu=8 并行运行的程序,它非常快。干杯 - 托尼
    • 已在 Revolution R v6.1 的最新 x64 位编译中修复(现在 64 位完全支持 doSMP)。
    【解决方案2】:

    这是很久以前修复的,在最新的 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)

    【讨论】:

      【解决方案3】:

      Revolution R 安装文件夹中有一个不错的 .pdf 文档,位于 Start..All Programs..Revolution R..Documentation..foreach and iterators - User's Guide 下。该文档描述了在运行 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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-01-10
        相关资源
        最近更新 更多