我已经在 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"
非常感谢您的帮助。
托尼