I am “lucky” to have access to a remote Rstudio server with 80 cores and I would like to use this server to run 5 stan models in parallel (each model runs 4 chains, so I would use 20 cores). I have tried the following:
library(parallel)
tasks <- list(
fit1<-function() sampling(model1,standata,cores=4),
fit2<-function() sampling(model2,standata,cores=4),
fit3<-function() sampling(model3,standata,cores=4),
fit4<-function() sampling(model4,standata,cores=4),
fit5<-function() sampling(model5,standata,cores=4)
)
out <- mclapply(
tasks,
function(f) f(),
mc.cores = 20
)
When I call mclapply
, model1 is properly sampled but I get some errors for the other models:
Warning message:
In mclapply(tasks, function(f) f(), mc.cores = 20) :
scheduled cores 3, 2, 4, 5 encountered errors in user code, all values of the jobs will be affected
Error in socketConnection(master, port = port, blocking = TRUE, open = "a+b", :
impossible to open the connection
Calls: <Anonymous> ... tryCatchOne -> doTryCatch -> recvData -> makeSOCKmaster
De plus : There were 17 warnings (use warnings() to see them)
Stopped execution
Error in socketConnection(master, port = port, blocking = TRUE, open = "a+b", :
impossible to open the connection
Calls: <Anonymous> ... tryCatchOne -> doTryCatch -> recvData -> makeSOCKmaster
De plus : There were 17 warnings (use warnings() to see them)
Stopped execution
Error in socketConnection(master, port = port, blocking = TRUE, open = "a+b", :
impossible to open the connection
Calls: <Anonymous> ... tryCatchOne -> doTryCatch -> recvData -> makeSOCKmaster
De plus : There were 17 warnings (use warnings() to see them)
Stopped execution
Error in socketConnection(master, port = port, blocking = TRUE, open = "a+b", :
impossible to open the connection
Calls: <Anonymous> ... tryCatchOne -> doTryCatch -> recvData -> makeSOCKmaster
De plus : There were 17 warnings (use warnings() to see them)
Stopped execution
Does anybody know how I can fix this?
Thank you in advance!