Closed dashaub closed 6 years ago
Can you try with Socket cluster? It worked on Windows with R 3.3.3:
library(parallel)
cl <- makeCluster(6)
clusterEvalQ(cl,library(forecastHybrid))
clusterEvalQ(cl,seriesHorizon <- 18)
forecasts <- pblapply(dat,
FUN = function(x) forecast(hybridModel(y = x, models = "aft",
verbose = FALSE),
h = seriesHorizon, level = 95,
PI.combination = "mean"),
cl = cl)
stopCluster(cl)
table(sapply(forecasts, class))
# forecast
# 20
Or see if parallel::mclapply
gives you the same issue:
numCores <- 6
forecasts <- parallel::mclapply(dat,
FUN = function(x) forecast(hybridModel(y = x, models = "aft",
verbose = FALSE),
h = seriesHorizon, level = 95,
PI.combination = "mean"),
mc.cores = numCores)
Good debugging advice.
Everything works fine with the socket cluster approach.
When using mclapply()
, I get errors when I use numCores
> 1, but it works fine when numCores <- 1
So it looks like there must be something going on with the "parallel" package breaking forking inside the Docker container.
Good to know it is a Docker/forking issue. A quick web search gave several hits with strange behaviour, but nothing too related to this. Something to watch for!
Apologies that this is neither minimal nor fully reproducible, but it is at least an example.
Setup
dat.gz This is running on R 3.4.4 (built from source) inside a Docker container on Debian Stretch from the Rocker images:
I was also not able to reproduce this behavior with R 3.4.4 on OSX, and I've tried setting
numCores <- 1
inside the Docker container and everything seems to work. Here are the minimal sets of packages necessary to reproduce the bug:Bug report
The seeds really should not be necessary since all of the functions are deterministic, but I set them anyway. A regular for loop produces expected results where all objects are of class "forecast":
Everything still works when using
lapply
:However, with
pblapply()
some of the jobs fail silently.And once more. There are failures again, but they do not reproduce the earlier results.
I can keep running the process with
pblapply()
and get different failures each time.