1

I am trying to add parallel computation option to an R (netresponse) package based on doMC and multicore. The script works ok, but only on the second trial.

To reproduce the bug, start R and run the script below. It gets stuck on the last line. After interrupting with ctrl-c I get a few messages of "select: Interrupted system call". Then, running the same script again will give the expected result without problems.

Is some further initialization needed to get this work properly already on the first run? Or any other tips?

thanks for your support, - L


require(netresponse)
require(multicore)
require(doMC)   
registerDoMC(3)
print(getDoParWorkers())
res <- foreach(i = 1:100, .combine = cbind, 
        .packages = "netresponse") %dopar% netresponse::vdp.mixt(matrix(rnorm(1000), 100, 10))

2 Answers 2

1

Heres the list of dependencies from the help page for package netresponse: "Depends: methods, igraph, graph, minet". I suspect that you are not getting all of them to the workers by just listing "netresponse" on the .packages argument.

1
  • Right. However this does not solve the issue. I am using version 1.5.13 of netresponse which has the dependencies listed below, but the same problem occurs also on previous versions. I added the dependencies now into the example as: require(c("netresponse", "doMC", "multicore", "graph", "igraph", "minet", "methods", "qvalue", "compiler")); registerDoMC(3); res <- foreach(i = 1:100, .combine = cbind, .packages = c("netresponse", "methods", "igraph", "graph", "minet", "qvalue", "compiler", "multicore", "doMC")) %dopar% netresponse::vdp.mixt(matrix(rnorm(1000), 100, 10))
    – antagomir
    Jul 17, 2011 at 22:05
0

Quick fix for problem with foreach %dopar% is to reinstall these packages:

install.packages("doSNOW")

install.packages("doParallel") 

install.packages("doMPI")

As mentioned in various threads at StackOverflow, these are responsible for parallelism in R. Bug which existed in old versions of these packages is now removed. I should mention that it will most likely help even though you are not using these packages in your project/package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.