Ubuntu 20.10: Problems installing rstan/brms

Ubuntu 20.10 fully updated (R 4.0.2)
Did follow instructions from RStan Getting Started · stan-dev/rstan Wiki · GitHub for installation. Code used below:

mydata <- data.frame(
    ind = factor(rep(1:28,  each=2)),
    Method = factor(rep(LETTERS[1:2], 28)), 
    Y      = c(rep(c(1, 1), 11),
                rep(c(0, 1), 6),
                rep(c(0, 0), 11)))
library(brms)

mod.brm <- brms::brm( Y  ~ Method + (1 | ind),
                     data=mydata, family=bernoulli,
                     chains=4, iter=2000)

Output:

Compiling Stan program…
Error in system.file(“lib”, .Platform$r_arch, package = “RcppParallel”, :
no file found
Error in sink(type = “output”) : invalid connection

Can you try installing the RcppParallel package?

It is installed. I should have given this:

sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.10

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
[4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
[7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] RcppParallel_5.0.2 brms_2.14.4 Rcpp_1.0.6 lme4_1.1-26
[5] Matrix_1.3-2 MASS_7.3-53

loaded via a namespace (and not attached):
[1] nlme_3.1-152 matrixStats_0.58.0 xts_0.12.1
[4] threejs_0.3.3 rstan_2.21.2 backports_1.2.1
[7] tools_4.0.2 R6_2.5.0 DT_0.17
[10] DBI_1.1.1 mgcv_1.8-33 projpred_2.0.2
[13] colorspace_2.0-0 withr_2.4.1 tidyselect_1.1.0
[16] gridExtra_2.3 prettyunits_1.1.1 processx_3.4.5
[19] Brobdingnag_1.2-6 emmeans_1.5.4 curl_4.3
[22] compiler_4.0.2 cli_2.3.0 shinyjs_2.0.0
[25] sandwich_3.0-0 colourpicker_1.1.0 scales_1.1.1
[28] dygraphs_1.1.1.6 mvtnorm_1.1-1 ggridges_0.5.3
[31] callr_3.5.1 StanHeaders_2.21.0-7 stringr_1.4.0
[34] digest_0.6.27 minqa_1.2.4 base64enc_0.1-3
[37] pkgconfig_2.0.3 htmltools_0.5.1.1 fastmap_1.1.0
[40] htmlwidgets_1.5.3 rlang_0.4.10 shiny_1.5.0
[43] generics_0.1.0 zoo_1.8-8 jsonlite_1.7.2
[46] crosstalk_1.1.1 gtools_3.8.2 dplyr_1.0.4
[49] inline_0.3.17 magrittr_2.0.1 loo_2.4.1
[52] bayesplot_1.8.0 munsell_0.5.0 abind_1.4-5
[55] lifecycle_0.2.0 multcomp_1.4-16 stringi_1.5.3
[58] yaml_2.2.1 pkgbuild_1.2.0 plyr_1.8.6
[61] grid_4.0.2 blob_1.2.1 parallel_4.0.2
[64] promises_1.1.1 crayon_1.4.1 miniUI_0.1.1.1
[67] fortunes_1.5-4 lattice_0.20-41 splines_4.0.2
[70] ps_1.5.0 pillar_1.4.7 igraph_1.2.6
[73] boot_1.3-26 estimability_1.3 markdown_1.1
[76] shinystan_2.5.0 codetools_0.2-18 reshape2_1.4.4
[79] stats4_4.0.2 rstantools_2.1.1 glue_1.4.2
[82] V8_3.4.0 vctrs_0.3.6 nloptr_1.2.2.2
[85] httpuv_1.5.5 gtable_0.3.0 purrr_0.3.4
[88] assertthat_0.2.1 ggplot2_3.3.3 mime_0.9
[91] xtable_1.8-4 coda_0.19-4 later_1.1.0.1
[94] survival_3.2-7 rsconnect_0.8.16 tibble_3.0.6
[97] shinythemes_1.2.0 gamm4_0.2-6 statmod_1.4.35
[100] TH.data_1.0-10 ellipsis_0.3.1 bridgesampling_1.0-0

Are you able to run the RStan example model:

example(stan_model, package = "rstan", run.dontrun = TRUE)

This happens:

example(stan_model, package = “rstan”, run.dontrun = TRUE)

stn_md> stancode ← ‘data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}’

stn_md> mod ← stan_model(model_code = stancode, verbose = TRUE)

TRANSLATING MODEL ‘16a540c6086086816528e4524def24d9’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘16a540c6086086816528e4524def24d9’.
COMPILING THE C++ CODE FOR MODEL ‘16a540c6086086816528e4524def24d9’ NOW.
OS: x86_64, linux-gnu; rstan: 2.21.2; Rcpp: 1.0.6; inline: 0.3.17
Error in system.file(“lib”, .Platform$r_arch, package = “RcppParallel”, :
no file found

Can you restart R and then try reinstalling RcppParallel and running the example again?

I had installed RcppParallel via the ubuntu package r-cran-RcppParalell. I uninstalled that, and reinstalled from source via install.packages. There are still problems, but it reaches longer. Output is now:

example(stan_model, package = “rstan”, run.dontrun = TRUE)

stn_md> stancode ← ‘data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}’

stn_md> mod ← stan_model(model_code = stancode, verbose = TRUE)

TRANSLATING MODEL ‘16a540c6086086816528e4524def24d9’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘16a540c6086086816528e4524def24d9’.
COMPILING THE C++ CODE FOR MODEL ‘16a540c6086086816528e4524def24d9’ NOW.
OS: x86_64, linux-gnu; rstan: 2.21.2; Rcpp: 1.0.6; inline: 0.3.17

setting environment variables:
PKG_LIBS = ‘/usr/lib/R/site-library/rstan/lib//libStanServices.a’ -L’/usr/lib/R/site-library/StanHeaders/lib/’ -lStanHeaders -L’/usr/local/lib/R/site-library/RcppParallel/lib/’ -ltbb
PKG_CPPFLAGS = -I"/usr/local/lib/R/site-library/Rcpp/include/" -I"/usr/lib/R/site-library/RcppEigen/include/" -I"/usr/lib/R/site-library/RcppEigen/include/unsupported" -I"/usr/lib/R/site-library/BH/include" -I"/usr/lib/R/site-library/StanHeaders/include/src/" -I"/usr/lib/R/site-library/StanHeaders/include/" -I"/usr/local/lib/R/site-library/RcppParallel/include/" -I"/usr/lib/R/site-library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include ‘/usr/lib/R/site-library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp’ -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1
Program source :
<<< I REMOVE A LOT OF THIS PRINTING OF SOURCE >>>

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
650 | return internal::first_aligned<int(unpacket_traits::alignment),Derived>(m); | ^~~~~~~~~/usr/bin/ld: /usr/lib/R/site-library/rstan/lib//libStanServices.a(stan_fit.o): relocation R_X86_64_PC32 against undefined hidden symbol `_ZTCN5boost10wrapexceptISt14overflow_errorEE0_NS_16exception_detail10clone_implINS3_19error_info_injectorIS1_EEEE’ can not be used when making a shared object/usr/bin/ld: final link failed: bad valuecollect2: error: ld returned 1 exit statusmake: *** [/usr/share/R/share/make/shlib.mk:6: filee973639100f.so] Error 1

That’s good progress actually!

Next, can you reinstall RStan and StanHeaders from source:

# Compile packages using all cores
Sys.setenv(MAKEFLAGS = paste0("-j",parallel::detectCores()))

install.packages(c("StanHeaders","rstan"),type="source")

Thanks! Did the reinstallation from source, Now the example runs. Still some problems with my simple model, but the chains seem to start, so now the problems are with the model …

Thanks!

2 Likes