0

I get the correct output when I use %do% (sequential processing) in foreach

However, the the script gets stuck when I try %dopar% (parallel processing) in foreach

for(i in seq(10,8,-2)){

   for(j in seq(10,8,-2)){

     foreach(k = 96:100,.packages=c('recommenderlab','ggplot2','reshape2') ) %dopar% {  

      results <- run_algorithms(r.binary, "cross", k, k)

      #plot the performance of the three algos
      jpeg(sprintf('u_%d_d_%d_%d.jpg',i,j,k))
      plot(results,annotate=c(1,3),legend="topleft")  

      dev.off()  
      }
    }
}
Rihan
  • 31
  • 1
  • 4
  • Usually indicative of an improperly configured parallel backend. How did you set up your parallel backend? Show output of `sessionInfo()` and include code used to set up the backend. – tchakravarty Jan 24 '16 at 05:12
  • I was using this: registerDoParallel(detectCores()) now i am using this: cl<-makeCluster(8) registerDoParallel(cl) – Rihan Jan 24 '16 at 05:17
  • Please provide `sessionInfo()` -- depending on the type of system you are on, many things could be going wrong including file permissions to install and load packages in the slave processes and writing to disk. – tchakravarty Jan 24 '16 at 06:27
  • We will need the entire code and data to reproduce this. Please provide us with a reproducible example ([here are some suggestions](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)). – Roman Luštrik Jan 24 '16 at 07:51
  • Thank you guys for your suggestions, the problem solved when i assigned the foreach to a variable like in the examples in official documentation: result <- foreach(k = 96:100,.packages=c('recommenderlab','ggplot2','reshape2')) %dopar% { ...} I will provide a reproducible example also. – Rihan Jan 25 '16 at 00:11

0 Answers0