2010-11-27 84 views
4

我已经在Windows 7上安装了R(64位)版本2.11.1,并且还包含了用于并行处理的“REvolution foreach windows bundle”中的doSMP和revoIPC。然后我上传库doSMP到R和来自RR在Windows 7上的64位并行处理doSMP

> 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" 

你的帮助非常感谢。

托尼

回答

1

错误消息

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

是很明确的:你正在运行64位的R,但你没有加载doSMP所需的所有子组件,尤其是封装revoIPC不见了。

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

+0

谢谢德克。可能我会在带有doMC的Linux平台上尝试。我是否正确,doSMP目前仅适用于Windows上的32位R? – Tony 2010-11-27 05:19:51

0

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 
1

这是很久以前的固定,而在转速R V6.1的最新的64位编译很好地工作。

下面的示例摘自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内置转速R核心打造,所以你不必从CRAN安装(因为这个原因,你不会找到它的包装清单上)。你所要做的就是用require(SMP)加载它。在类似的说明中,包含parallel的软件包也从v2.14.0开始构建到R的所有版本中,并使用require(parallel)加载。

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