Open andrjohns opened 4 years ago
Additionally, it looks like the crashes don't occur if I manually trigger a garbage collection between each brms
run:
options(mc.cores=4)
library(brms)
load("test_brm.RData")
out = do.call(brm,test_brm)
gc()
out = do.call(brm,test_brm)
gc()
out = do.call(brm,test_brm)
gc()
out = do.call(brm,test_brm)
gc()
out = do.call(brm,test_brm)
gc()
out = do.call(brm,test_brm)
gc()
out = do.call(brm,test_brm)
I did a little more playing around (see the 994 issue in brms), and found that if I call brm twice, then do a gc(), it crashes during the gc() step:
options(mc.cores=4)
library(brms)
load("test_brm.RData")
out = do.call(brm,test_brm)
out = do.call(brm,test_brm)
gc() #crashes at this step
So, whether I do a 3rd do.call(brm, test_brm) or two of those and then a gc(), it's during the third step that the crash occurs.
An example of this crashing behaviour using just RStan-only code also recently popped up on the forums: https://discourse.mc-stan.org/t/random-but-consistent-c-stack-error-on-windows-10/17799/4
Another thing I just noticed that returned the C stack trace issue on the Windows VM from our GitHub Actions—I'm not quite sure it the above will break universally, but thought I'd post it here for you to give it a go as well. Even if I rename all objects differently, but remove each before running the next, it breaks.
options(mc.cores=4)
library(brms)
load("test_brm.RData")
out_1 = do.call(brm,test_brm)
rm(out_1)
out_2 = do.call(brm,test_brm)
rm(out_2)
out_3 = do.call(brm,test_brm)
rm(out_3)
out_4 = do.call(brm,test_brm) #crashes at this step
I did a little more playing around (see the 994 issue in brms), and found that if I call brm twice, then do a gc(), it crashes during the gc() step:
options(mc.cores=4) library(brms) load("test_brm.RData") out = do.call(brm,test_brm) out = do.call(brm,test_brm) gc() #crashes at this step
So, whether I do a 3rd do.call(brm, test_brm) or two of those and then a gc(), it's during the third step that the crash occurs.
Just adding here that these steps crash my R session too.
Has any progress been made on this?
I am having very similar issues. For my personal use, I use cmdstanr
which works well.
However, I am working on a package and cmdstanr
is a difficult setup to use / depend on for unit testing and Vignettes for CRAN and things like GitHub actions as R
packages do not have a convenient way to specify they depend on cmdstanr
and cmdstan
being successfully installed.
Summary:
Following on from this issue in the brms repo, the R session on Windows will crash when repeatedly assigning to the same output.
This is most easily replicated with
brms
. Using this list of brms arguments: test_brm.RData, the crash can be replicated via:However, when I extract the Stan code, data and initial values from the
brms
object into test_rstan.txt and do the same runs with 'pure' RStan, I don't get the same failures:This leads me to believe the crash is related to the model compilation in some way, since the
brms
calls re-compile the model each time, but therstan
calls do not (even if I setrstan_options(auto_write = FALSE)
)Contents of my Makevars & .Renviron files:
Session Info: