Issues with foreach and SGE #687
-
|
furrr works perfectly with future.batchtools. If you have a loop with 3 elements you get 3 jobs on the cluster: library(furrr)
library(future.batchtools)
plan(batchtools_sge)
nothingness <- future_map(c(2, 2, 2), ~Sys.sleep(.x))
qstatWith foreach, however, I only get 1 job: library(foreach)
library(future)
library(furrr)
library(future.batchtools)
library(doFuture)
mu <- 1.0
sigma <- 2.0
registerDoFuture()
plan(batchtools_sge)
x %<-% {
foreach(i = 1:3) %dopar% {
Sys.sleep(3)
set.seed(123)
rnorm(i, mean = mu, sd = sigma)
}
}qstatand when it return we get the following 2 strange warnings:
Why does it say there is no parallel backend registered when I'm running registerDoFuture()? Alternatively, I tried %dofuture% instead of %dopar% but it still only generates 1 job. x %<-% {
foreach(i = 1:10) %dofuture% {
Sys.sleep(3)
set.seed(123)
rnorm(i, mean = mu, sd = sigma)
}
}
f = futureOf(x)
resolved(f)
x
qstatThis time I only get the random number warning:
I also tried other options in foreach like Is it possible that foreach somehow chunks all the iteration in one task? Or is something else not working. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
|
TLDR: I was hoping to save Henrik a bit of time but alas I failed. Thanks for that nice minimal example. Regarding the issue about the seed, you can read about the purpose of the warning in Here is the code I ran, based on your code (note the addition of However, I still get the following warning: |
Beta Was this translation helpful? Give feedback.
-
|
By the way, in your real example do you indeed want to set |
Beta Was this translation helpful? Give feedback.
-
|
I'm not at a computer right now, but you don't want to use |
Beta Was this translation helpful? Give feedback.
I'm not at a computer right now, but you don't want to use
%<-%here (for the same reason you don't use it withfuture_map()) - just use a regular<-assignment.