Why does pbsapply gets stuck when multiple cores are used?

27 views Asked by At

I have code of the form:

clus <- makeCluster(7) 
clusterExport(clus, c("gen_dat", "run_simulation", "grid", "get_models"))
clusterEvalQ(clus, {
  library(cmdstanr)
  library(dplyr)})

pbsapply(1:nrow(grid), run_simulation, folder = "simplex")

This runs. However, if I do

pbsapply(1:nrow(grid), run_simulation, folder = "simplex", cl = clus)

sometimes it runs, and sometimes it doesn't. By 'doesn't' run' I mean that sometimes the code works perfectly. But other times, the functions starts executing and gets stuck forever. The progress bar is stuck at 0%, and no output is generated (in each iteration, some model results are saved; but none is saved).

The code is simple, but this behaviour is puzzling me. Does anybody know what might be going on? I am running this on Windows, in a laptop with 8 cores. Anybody knows where this kind of behaviour might be coming from?

Thanks in advance.

0

There are 0 answers