开发者

Parallel processing in R with 64-bit on Windows 7- package doSMP

I have installed R (64-bit) version 2.11.1 on Windows 7 and also packages doSMP and revoIPC from "REvolution foreach windows bundle" for parallel processing. I then uploaded library doSMP into R and got following messages from R

> library(doSMP)
Loading required package: revoIPC
Error: package 'revoIPC' is not installed for 'arch=x64'

How to get around this problem? It seems that doSMP works on a 32 bit distribution of R but not the 64 bit distribution.

I also tested the following programme

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

And I got the following messages from R

> workers <- startWorkers(4) # My computer has 2 cores
Error: could not find function "startWorkers"
> registerDoSMP(workers)
Error: could not find function "registerDoSMP"

Many thanks for your help.

Tony


The error message

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

is pretty explicit: you are running 64-bit R, but you do not have all sub-components needed to load doSMP, in particular the package revoIPC is missing.

If you are a Revo customer, contact them. If not, then maybe you need to consider different parallel computing solutions for R.


This was fixed a long time ago, and works nicely in the latest 64-bit build of Revolution R v6.1.

The example below was taken from Parallel Multicore Processing with R (on Windows), and works nicely on my machine which is running Revolution R v6.1 x64 on Windows 7 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)

Note that the package doSMP is built into the core build of Revolution R, so you don't have to install it from CRAN (for this reason, you won't find it on the package list). All you have to do is load it with require(SMP). On a similar note, the package parallel is also built into all versions of R from v2.14.0 onwards, load it with require(parallel).

For more important notes on this example, see the full article Parallel Multicore Processing with R (on Windows).


There is a nice .pdf document in the Revolution R installation folder, under Start..All Programs..Revolution R..Documentation..foreach and iterators - User's Guide. The document describes how to parallelize a task in R when running Windows. Here are the topics that it covers:

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜