stan-dev / rstan

RStan, the R interface to Stan
https://mc-stan.org
1.02k stars 264 forks source link

R crashes during sampling #1070

Open wpfl-dbt opened 1 year ago

wpfl-dbt commented 1 year ago

I'm trying to install rstan to go through Statistical Rethinking, and when I try to verify the installation with example(stan_model, package = "rstan", run.dontrun = TRUE), I get "R encountered a fatal error. The session was terminated". This occurs during the line stan_md> fit <- sampling(mod, data = list(y_mean = 0)) in the console.

This happens whether I install from CRAN or from mc-stan.org. With the second, even though the site suggests I should get 2.26, the version of rstan that comes back from install.packages is 2.21.8, the same as CRAN, so I don't know if that has something to do with it.

I don't know if this is extraneous information, but I have a working installation of CmdStan and CmdStanR, also required for the book. My hunch is there could be some conflict there.

Here's my versions:

Intel macOS Ventura 13.3.1 RStudio 2023.03.1+446 R version 4.3.0 rstan 2.21.8 StanHeaders 2.26.25

henryrscharf commented 1 year ago

I am experiencing a similar issue, but across mac, linux (ubuntu), and windows implementations. For me, the issue appears to be that a massive amount of memory is used during once sampling is initiated, which ultimately crashes R.

henryrscharf commented 1 year ago

I tracked my issue back to a recent update for StanHeaders. Re-installing the archived version StanHeaders_2.21.0-7.tar.gz seems to have fixed my memory issue.

jsocolar commented 1 year ago

@andrjohns see also https://discourse.mc-stan.org/t/rstan-segfaults-on-macos-ventura-13-4/31547

andrjohns commented 1 year ago

Until we have rstan 2.26 on CRAN if you update to StanHeaders 2.26 then you need to also reinstall rstan 2.21 from source

kjayhan commented 1 year ago

Until we have rstan 2.26 on CRAN if you update to StanHeaders 2.26 then you need to also reinstall rstan 2.21 from source

I use rstan_2.21.8 and StanHeaders_2.26.26, but still when I run "example(stan_model, package = "rstan", run.dontrun = TRUE)"

I get "R session aborted".

R version 4.3.0 (2023-04-21) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Ventura 13.4

kjayhan commented 1 year ago

Until we have rstan 2.26 on CRAN if you update to StanHeaders 2.26 then you need to also reinstall rstan 2.21 from source

I use rstan_2.21.8 and StanHeaders_2.26.26, but still when I run "example(stan_model, package = "rstan", run.dontrun = TRUE)"

I get "R session aborted".

R version 4.3.0 (2023-04-21) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Ventura 13.4

Finally this worked for me: https://discourse.mc-stan.org/t/installing-rstan/20743/2

mschubert commented 10 months ago

I'm observing a similar issue specific to rstan=2.21.8 (which is the current version on CRAN): massively increasing memory usage during warmup/sampling, in the 100s of GB. 2.21.7 stays under 2 GB for my model.

Both are using StanHeaders=2.26.27 (also current CRAN). This is on vanilla R=4.3.1 on Gentoo.

Alternatively, using StanHeaders=2.21.0-7, sampling works fine when using rstan=2.21.8

Until we have rstan 2.26 on CRAN if you update to StanHeaders 2.26 then you need to also reinstall rstan 2.21 from source

Ultimately, re-installing both StanHeaders=2.26.27 and rstan=2.21.8 (in this order) from source solved the issue for me.