I have a feeling that this is more an RStudio issue than an rstan issue, but I wanted to check and see if anyone else has experienced. I am fitting some moderately large Stan models with R 4.0 and rstan 2.19.3 (StanHeaders 2.21.0-3) on Windows 10. These models take a long time to compile - several minutes but not quite an hour. When the model finally starts running in parrallel the RStudio Viewer window comes alive, which I’m quite familiar with from older versions of RStudio and rstan. However, when I attempt to refresh the page to see the status of my changes I get this message:
“The process cannot access the file because it is being used by another process.”
I have verified that I do not get this message and get the expected behavior with smaller models (e.g. the 8schools example model). Before I flag an issue with RStudio, I just wanted to see if anyone else is experiencing this or has a workaround.
I just updated to R 4.0.0 and Rstudio 1.3.959, and also updated Rtools and rstan at the same time, and now am having the same issue reported here (cannot view progress on viewer). The model fitting is successful, and once it is done I can view the results in viewer, however when I try and refresh the Viewer window to see progress while it is running I get the “The process cannot access the file because it is being used by another process.” error message
I also upgraded to R 4.0.0 and Rstudio 1.3.959 and had the same problem. Went back to Rstudio 1.2.5042 and it worked. So, definitely is an issue of the latest Rstudio version.
before you run rstan (each time after you restarted R).
That’s what is recommended in the thread @ssp3nc3r linked to and it works for me. (Though this solves a problem with the parallel package under R 4.0, so it might not solve you problem. Still worth a try.)
The bug still exists. I’m in R 4.0.2 and Rstudio 1.2.5033 and it still is failing to run parallel chains in rstan. Again, it runs fine in the regular R console.
Hey Andrew, I think @Dalton was running the RStudio preview build (version 1.3.1054 compared to your version 1.2.5033). The bug fix may not have made it into an RStudio release yet. Here’s the page where you can download the preview version of RStudio if you want:
Oh, I see what happened. I’d downloaded the latest Rstudio but I’d neglected to put it in my Applications folder, so my computer was still running the old version.
I now am using Rstudio version 1.3.959, and . . . it still doesn’t work! I guess I’ll wait until 1.3.1054 is in the regular version of Rstudio.
I hope this does not confuse readers of Regression and Other Stories! I don’t think we’re using parallel processing in the book code, but currently when you do library(“rstanarm”), you get this message:
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores())
Now I wish we’d just recommended R, not Rstudio, in the book!
Yeah hopefully they’ll do an RStudio release before the book comes out in a few weeks, but either way I think it was the right choice to recommend RStudio. Plus, most readers will probably be using RStudio whether or not it’s recommended in the book (I rarely encounter R users who aren’t using RStudio now, although there are certainly some).
But yeah this is a frustrating bug. I don’t know if they have a release date set for RStudio, but maybe we should change the startup message from rstanarm to mention this problem until it’s fixed?
In case this helps, for a completely unrelated issue I just did a fresh install (uninstalled R and the RTools + deleted the folders in my PC) and following the instructions on the RStan guide (including installing RTools with the command they put in there) solved this problem, now I can monitor my chains in the viewer when clicking refresh (which wasn’t working on my Rstudio 1.3.59)