Installing rstan crashes Rstudio

I'm trying installing rstan using install.packages('rstan')

It gets laggy and then automatically closes Rstudio. I have tried
install.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild"))
but that didn't help.

I'm using Ubuntu 22.04.2 LTS.

What else could I try?

I am almost certain that you are running out of memory while installing rstan.

Does the install.packages() command with the multiple packages finish successfully ? Is it "just" the rstan package that makes RStudio close ?

Could you try to increase memory for your RStudio ?

Also take a look at RStan Getting Started · stan-dev/rstan Wiki · GitHub which describes the installation of a more recent version of rstan.

The multiple packages were successfully installed. So it's jut the rstan package makes Rstudio close (and also Firefox while I was browsing the web). Could you tell me how to check how much memory is being used for Rstudio and how to increase the amount? I'm using Ubuntu 22.04

The amount of memory used you always can find in the memory report in the RStudio IDE (top right part of the IDE in the Environment/History/... part.

Unless you set any limitations on the system side or add limits into local launcher or even use SLURM launcher, RStudio will consume all the memory it can get before running out of it and then the so-called OOM will kill the process that consumes the most of memory - this is when RStudio will close according to my theory.

As a next step, can you please open a terminal in the RStudio IDE (Alternatively log into your ubuntu 22.04 server via ssh), type the following commands

curl -O https://mc-stan.org/r-packages/src/contrib/rstan_2.26.22.tar.gz
R CMD INSTALL rstan_2.26.22.tar.gz

and send the output ? (If the second command complains about "R not found" you may need to specify the full path to the R binary (e.g. /opt/R/4.2.3/bin/R)

I ended up successfully installing rstan in my Ubuntu termial (not in the Rstudio terminal). Does that suggest anything? I tried your commands and it told me

sudo snap install curl # version 8.1.2, or
sudo apt install curl # version 7.81.0-1ubuntu1.13
See 'snap info curl' for additional versions.
Warning: invalid package ‘rstan_2.26.22.tar.gz’
Error: ERROR: no packages specified

I also navigated to Environment tab, pressed Free unused memory and I got this

gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 2715225 145.1 4524922 241.7 4524922 241.7
Vcells 5064424 38.7 10146329 77.5 7437365 56.8

clicked the Memory usage report, I got
Screenshot from 2023-08-03 09-37-16

Can you see and instruct me next steps? I still want it smoother, I compiled a model and Rstudio closes again.

Sorry for the small delay here.

Can you please let me know the version of RStudio you are using ? R version is still R 4.2.3 ?

Furthermore, I would like to extract some more error messages from your Rstudio environment. Could you please

  • run sessionInfo() just before you run the STAN command that will close RStudio
  • run the commands you use to compile the STAN model etc... wrapped into
capture.output( your-command ,file="error.txt",type="message",append=TRUE)

where you replace your-command with the STAN command that closes RStudio ?

No problem, you're helping me out. I'm sorry that I can't embed more than one image so I split my reply into 3 answers.

I'm using Rstudo 4.3.1. This is the first shot from sessionInfor()

Then I load the libraries, the first two packages were loaded normally, I got other messages from the third

Next I loaded data and wrapped the codes which caused Rstudio (and also Firefox) closing:

capture.output( fit1_stan <- stan_foot(data = italy_2000, model="biv_pois", chains = 2, iter = 100), file="error.txt",type="message",append=TRUE)

It gave me a zero-byte .txt file (nothing inside). Here is my entire code

I'm a non-tech guy so please just tell me what you need to solve the problem.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.