Stan doesn't work in RStudio with multiple cores on Catalina

I initially tried to fit a model after updating to Catalina on my Mac, and it didn’t work.

I followed the advice by Ben here: Dealing with Catalina III and Stan appeared to be working in R as well as RStudio.

However, it is quite buggy in RStudio particularly – the model will compile and sample as long as the cores argument is left to default 1. However, if I try to increase the number of cores to >1 then the console will not sample and gets stuck at the “starting worker…” and I get this error:

"Error in unserialize(node$con) : error reading from connection
Calls: -> slaveLoop -> makeSOCKmaster
Error in unserialize(node$con) : error reading from connection
Calls: -> slaveLoop -> makeSOCKmaster
Execution halted
Execution halted
Error in unserialize(node$con) : error reading from connection
Calls: -> slaveLoop -> makeSOCKmaster
Execution halted
Error in unserialize(node$con) : error reading from connection
Calls: -> slaveLoop -> makeSOCKmaster
Execution halted
Error in makePSOCKcluster(names = spec, …) :
Cluster setup failed. 4 of 4 workers failed to connect.
"

This problem doesn’t occur if I use the R console directly and run the exact same model/code.

I’m using R version 4.0.2 & Rstudio Version 1.3.959.

Appeared to find the solution here: R 4.0.0 and CRAN MacOS binaries?

Be sure to change the R version in that solution to whatever R version you’re using.

1 Like