stan-dev / rstan

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

Cannot install on Google Colaboratory #790

Open hirokisince1998 opened 4 years ago

hirokisince1998 commented 4 years ago

Summary:

RStan installation on Google Colaboratory now fails.

Description:

"apt install r-cran-rstan" suddenly stopped working. On Google Colaboratory, the following script is expected to set up a working RStan environment, as described in Installing RStan on Linux.

system("add-apt-repository -y ppa:marutter/c2d4u3.5")
system("apt update")
system("apt install r-cran-rstan")

However, the last step now fails, so the following "library(rstan)" also fails.

Reproducible Steps:

Open a notebook with: https://colab.research.google.com/notebook#create=true&language=r

Run the following code:

system("add-apt-repository -y ppa:marutter/c2d4u3.5")
system("apt update")
system("apt install r-cran-rstan",TRUE)

Current Output:

Warning message in system("apt install r-cran-rstan", TRUE):
"running command 'apt install r-cran-rstan' had status 100"
'Reading package lists...'
'Building dependency tree...'
'Reading state information...'
'Some packages could not be installed. This may mean that you have'
'requested an impossible situation or if you are using the unstable'
'distribution that some required packages have not yet been created'
'or been moved out of Incoming.''The following information may help to resolve the situation:'
''
'The following packages have unmet dependencies:'
' r-cran-rstan : Depends: r-cran-v8 but it is not going to be installed'

R Version:

R version 3.6.3 (2020-02-29)

Operating System:

Running on Google Colaboratory with IRkernel

JSenta commented 3 years ago

Hi, did you ever solve this? I am also unable to install rstan on Google Colab.

lakshinav commented 3 years ago

Hi, I've install V8 via command line and after that install rstan, see the notebook here. Sorry, it's too overexplained, bcs for students)

hirokisince1998 commented 3 years ago

Right. system("apt-get install -y libv8-dev") does the trick.

However, install.packages("rstan") takes unacceptably long time (some 15 minutes) for every colab instances, which makes its use for remote lecture almost impossible.

Still waiting for an update.

andrjohns commented 3 years ago

If you're installing RStan and all its dependencies in a fresh R instance on Colab (i.e., with no dependencies already installed), then it is naturally going to take a while. This is because RStan and its dependencies (and their dependencies) are being installed from source, which requires compilation for many packages. This is not an RStan issue, just a reality of installing packages on Linux distributions (which is what Colab uses).

You can speed up the compilation of packages by instructing R to use all available cores when building packages.

Simply run:

Sys.setenv(MAKEFLAGS= paste0("-j",parallel::detectCores()))

Before installing RStan