2010-11-27 81 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)