[repost following Yann’s answer by email so the HPC community can have access to the answer]
Dear HPC team,
I’m trying to install the Rstan R package (and most importantly it’s dependency Rstanarm) on my Yggdrasil session. I’ve found this forum: Installation of Rstan package for R but the solution is unfortunately not working for me.
First, I use an R script (file name = “install_Rstan.R
”) to install the package, following instructions available here (RStan Getting Started · stan-dev/rstan Wiki · GitHub):
remove.packages(c("StanHeaders", "rstan"))
install.packages("rstan", repos = https://cloud.r-project.org/, dependencies = TRUE)
My sbatch (file name = "Rbayes.sh
") :
#!/bin/bash
#SBATCH –-job-name=HPCJPR
#SBATCH –-ntasks-per-node=1
#SBATCH –-cpus-per-task=1
#SBATCH –-mem-per-cpu=5000
#SBATCH –-time=00:30:00
#SBATCH –-partition=shared-cpu
#SBATCH –-mail-type=ALL
ml GCC/10.3.0 OpenMPI/4.1.1 R/4.1.0 nodejs
INFILE=install_Rstan.R
OUTFILE=install-packages-${SLURM_JOBID}.Rout
Srun R CMD BATCH $INFILE $OUTFILE
The job launches with no issue with the sbatch command in the linux console. The dependencies of the ‘rstan’ package are installed without an issue. The problem comes when it is time to install ‘rstan’: it seems to come from g++, the error is the following:
.Rprofile: Setting Switzerland repository
* installing *source* package ‘rstan’ ...
** package ‘rstan’ successfully unpacked and MD5 sums checked
** using non-staged installation
** libs
g++ -std=gnu++17 -I"/opt/ebsofts/R/4.1.0-foss-2021a/lib64/R/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"/home/users/r/richetta/Rpackages/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -D_REENTRANT -DSTAN_THREADS -DUSE_STANC3 -DSTRICT_R_HEADERS -D_HAS_AUTO_PTR_ETC=0 .Rprofile: Setting Switzerland repository -I'/home/users/r/richetta/Rpackages/Rcpp/include' -I'/opt/ebsofts/R/4.1.0-foss-2021a/lib64/R/library/RcppEigen/include' -I'/opt/ebsofts/R/4.1.0-foss-2021a/lib64/R/library/BH/include' -I'/home/users/r/richetta/Rpackages/StanHeaders/include' -I'/opt/ebsofts/R/4.1.0-foss-2021a/lib64/R/library/RcppParallel/include' -I/opt/ebsofts/OpenSSL/1.1/include -I/opt/ebsofts/libgit2/1.1.0-GCCcore-10.3.0/include -I/opt/ebsofts/GDAL/3.3.0-foss-2021a/include -I/opt/ebsofts/nodejs/14.17.0-GCCcore-10.3.0/include -I/opt/ebsofts/GLPK/5.0-GCCcore-10.3.0/include -I/opt/ebsofts/ImageMagick/7.0.11-14-GCCcore-10.3.0/include -I/opt/ebsofts/GSL/2.7-GCC-10.3.0/include -I/opt/ebsofts/UDUNITS/2.2.28-GCCcore-10.3.0/include -I/opt/ebsofts/HDF5/1.10.7-gompi-2021a/include -I/opt/ebsofts/ICU/69.1-GCCcore-10.3.0/include -I/opt/ebsofts/libsndfile/1.0.31-GCCcore-10.3.0/include -I/opt/ebsofts/FFTW/3.3.9-gompi-2021a/include -I/opt/ebsofts/NLopt/2.7.0-GCCcore-10.3.0/include -I/opt/ebsofts/GMP/6.2.1-GCCcore-10.3.0/include -I/opt/ebsofts/libxml2/2.9.10-GCCcore-10.3.0/include -I/opt/ebsofts/cURL/7.76.0-GCCcore-10.3.0/include -I/opt/ebsofts/Tk/8.6.11-GCCcore-10.3.0/include -I/opt/ebsofts/Core/Java/11.0.2/include -I/opt/ebsofts/LibTIFF/4.2.0-GCCcore-10.3.0/include -I/opt/ebsofts/libjpeg-turbo/2.0.6-GCCcore-10.3.0/include -I/opt/ebsofts/libpng/1.6.37-GCCcore-10.3.0/include -I/opt/ebsofts/PCRE2/10.36-GCCcore-10.3.0/include -I/opt/ebsofts/SQLite/3.35.4-GCCcore-10.3.0/include -I/opt/ebsofts/zlib/1.2.11-GCCcore-10.3.0/include -I/opt/ebsofts/XZ/5.2.5-GCCcore-10.3.0/include -I/opt/ebsofts/bzip2/1.0.8-GCCcore-10.3.0/include -I/opt/ebsofts/ncurses/6.2-GCCcore-10.3.0/include -I/opt/ebsofts/libreadline/8.1-GCCcore-10.3.0/include -I/opt/ebsofts/cairo/1.16.0-GCCcore-10.3.0/include -I/opt/ebsofts/libGLU/9.0.1-GCCcore-10.3.0/include -I/opt/ebsofts/Mesa/21.1.1-GCCcore-10.3.0/include -I/opt/ebsofts/X11/20210518-GCCcore-10.3.0/include -I/opt/ebsofts/FlexiBLAS/3.0.4-GCC-10.3.0/include -I/opt/ebsofts/FlexiBLAS/3.0.4-GCC-10.3.0/include/flexiblas -DSTRICT_R_HEADERS -fpic -O2 -ftree-vectorize -march=core2 -fno-math-errno -c chains.cpp -o chains.o
g++: error: .Rprofile:: No such file or directory
g++: error: Setting: No such file or directory
g++: error: Switzerland: No such file or directory
g++: error: repository: No such file or directory
make: *** [/opt/ebsofts/R/4.1.0-foss-2021a/lib64/R/etc/Makeconf:177: chains.o] Error 1
ERROR: compilation failed for package ‘rstan’
I’ve tried to add:
Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)
Before running the line to install rstan, with no success.
I haven’t configured C Toolchain for Linux (Configuring C Toolchain for Linux · stan-dev/rstan Wiki · GitHub) since I believe that this is already done (?), and I’m very hesitant to follow the steps. Would this be the missing link?
Finally, the weirdest part is that if I run my script from the console using
cat install_Rstan.r
and then I run
time Rscript test_lib.R
which contains
example(stan_model, package = "rstan", run.dontrun = TRUE)
the example runs. But the package never installs itself (in my Rpackages/ folder, there is no ‘rstan’ package).
I’m sorry to bother with such an issue, but I’m very confused by the g++ error.
Thanks for the help. All the best.