stan-dev / rstanarm

rstanarm R package for Bayesian applied regression modeling
https://mc-stan.org/rstanarm
GNU General Public License v3.0
389 stars 134 forks source link

Unable to install rstanarm on CentOS7 even though rstan installs OK #420

Closed leungi closed 4 years ago

leungi commented 4 years ago

Summary:

Able to install rstan, but not rstanarm.

Reviewed and tried suggestions fron #293, #408 and #394, but no luck.

Tried installing a few ways, and all give the same error message:

  1. from CRAN
  2. from RStudio Package Manager Linux binaries
  3. from RStudio Package Manager Source

Reproducible Steps:

> getwd()
[1] "/home/leungi"
> install.packages("rstanarm", repos = "http://adam.oxy.com:4242/prod-cran/__linux__/centos7/latest")
trying URL 'http://adam.oxy.com:4242/prod-cran/__linux__/centos7/latest/src/contrib/rstanarm_2.19.3.tar.gz'
Content type 'application/x-gzip' length 3525844 bytes (3.4 MB)
==================================================
downloaded 3.4 MB

* installing *source* package ârstanarmâ ...
** package ârstanarmâ successfully unpacked and MD5 sums checked
** using staged installation
** libs
"/opt/R/3.6.2/lib/R/bin/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" stan_files/lm.stan
Wrote C++ file "stan_files/lm.cc"

g++ -std=c++1y  -I"/opt/R/3.6.2/lib/R/include" -DNDEBUG -I"../inst/include" -I"/opt/R/3.6.2/lib/R/library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -I"/opt/R/3.6.2/lib/R/library/StanHeaders/include" -I"/opt/R/3.6.2/lib/R/library/rstan/include" -I"/opt/R/3.6.2/lib/R/library/BH/include" -I"/opt/R/3.6.2/lib/R/library/Rcpp/include" -I"/opt/R/3.6.2/lib/R/library/RcppEigen/include" -I/usr/local/include    -O3 -march=native -mtune=native -fPIC -Wno-unused-variable -Wno-unused-function -c stan_files/lm.cc -o stan_files/lm.o
In file included from /opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:6:0,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat.hpp:41,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/src/stan/model/test_gradients.hpp:7,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10,
                 from /opt/R/3.6.2/lib/R/library/rstan/include/rstan/stan_fit.hpp:35,
                 from /opt/R/3.6.2/lib/R/library/rstan/include/rstan/rstaninc.hpp:3,
                 from stan_files/lm.hpp:18,
                 from stan_files/lm.cc:3:
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:31:32: error: âstd::index_sequenceâ has not been declared
                           std::index_sequence<I...> i) {
                                ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:31:46: error: expected â,â or â...â before â<â token
                           std::index_sequence<I...> i) {
                                              ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In function  constexpr auto stan::math::internal::apply(const F&, const Tuple&)â:
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:27: error: âmake_index_sequenceâ is not a member of âstdâ
   return apply_impl(f, t, std::make_index_sequence<std::tuple_size<Tuple>{}>{});
                           ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:27: note: suggested alternative:
In file included from /opt/R/3.6.2/lib/R/library/BH/include/boost/fusion/container/vector/vector.hpp:28: ,
                 from /opt/R/3.6.2/lib/R/library/BH/include/boost/fusion/container/vector/vector10.hpp:2 ,
                 from /opt/R/3.6.2/lib/R/library/BH/include/boost/fusion/view/transform_view/transform_view.hpp:22,
                 from /opt/R/3.6.2/lib/R/library/BH/include/boost/fusion/algorithm/transformation/transform.hpp:11,
                 from /opt/R/3.6.2/lib/R/library/BH/include/boost/fusion/view/zip_view/detail/begin_impl.hpp:14,
                 from /opt/R/3.6.2/lib/R/library/BH/include/boost/fusion/view/zip_view/zip_view.hpp:16,
                 from /opt/R/3.6.2/lib/R/library/BH/include/boost/fusion/view/zip_view.hpp:12,
                 from /opt/R/3.6.2/lib/R/library/BH/include/boost/fusion/include/zip_view.hpp:11,
                 from /opt/R/3.6.2/lib/R/library/BH/include/boost/numeric/odeint/util/resize.hpp:26,
                 from /opt/R/3.6.2/lib/R/library/BH/include/boost/numeric/odeint/util/state_wrapper.hpp:26,
                 from /opt/R/3.6.2/lib/R/library/BH/include/boost/numeric/odeint/util/ublas_wrapper.hpp:33,
                 from /opt/R/3.6.2/lib/R/library/BH/include/boost/numeric/odeint.hpp:25,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/prim/arr/functor/integrate_ode_rk45.hpp:17,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/prim/arr.hpp:46,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/prim/mat.hpp:344,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/src/stan/model/test_gradients.hpp:7,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10,
                 from /opt/R/3.6.2/lib/R/library/rstan/include/rstan/stan_fit.hpp:35,
                 from /opt/R/3.6.2/lib/R/library/rstan/include/rstan/rstaninc.hpp:3,
                 from stan_files/lm.hpp:18,
                 from stan_files/lm.cc:3:
/opt/R/3.6.2/lib/R/library/BH/include/boost/fusion/support/detail/index_sequence.hpp:59:12: note:   âboost::fusion::detail::make_index_sequenceâ
     struct make_index_sequence
            ^
In file included from /opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:6:0,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat.hpp:41,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/src/stan/model/test_gradients.hpp:7,
                 from /opt/R/3.6.2/lib/R/library/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10,
                 from /opt/R/3.6.2/lib/R/library/rstan/include/rstan/stan_fit.hpp:35,
                 from /opt/R/3.6.2/lib/R/library/rstan/include/rstan/rstaninc.hpp:3,
                 from stan_files/lm.hpp:18,
                 from stan_files/lm.cc:3:
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:77: error: expected primary-expression before â{â token
   return apply_impl(f, t, std::make_index_sequence<std::tuple_size<Tuple>{}>{});
                                                                             ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:77: error: expected â)â before â{â token
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: At global scope:
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:151:9: error: expected type-specifier
       = std::result_of_t<F(decltype(is_var_), decltype(value_of(Targs()))...)>;
         ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:156:42: error: âFReturnTypeâ was not declared in this scope
   std::array<int, internal::compute_dims<FReturnType>::value> M_;
                                          ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:156:53: error: template argument 1 is invalid
   std::array<int, internal::compute_dims<FReturnType>::value> M_;
                                                     ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:156:61: error: template argument 2 is invalid
   std::array<int, internal::compute_dims<FReturnType>::value> M_;
                                                             ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In member function âstd::vector<stan::math::var> stan::math::adj_jac_vari<F, Targs>::build_return_varis_and_vars(const std::vector<double>&)â:
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:349:9: error: invalid types âint[int]â for array subscript
     M_[0] = val_y.size();
         ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:350:32: error: invalid types âint[int]â for array subscript
     std::vector<var> var_y(M_[0]);
                                ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In member function âEigen::Matrix<stan::math::var, R, C> stan::math::adj_jac_vari<F, Targs>::build_return_varis_and_vars(const Eigen::Matrix<double, R, C>&)â:
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:375:9: error: invalid types âint[int]â for array subscript
     M_[0] = val_y.rows();
         ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:376:9: error: invalid types âint[int]â for array subscript
     M_[1] = val_y.cols();
         ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:377:40: error: invalid types âint[int]â for array subscript
     Eigen::Matrix<var, R, C> var_y(M_[0], M_[1]);
                                        ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:377:47: error: invalid types âint[int]â for array subscript
     Eigen::Matrix<var, R, C> var_y(M_[0], M_[1]);
                                               ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In member function âvoid stan::math::adj_jac_vari<F, Targs>::chain()â:
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:530:5: error: âFReturnTypeâ was not declared in this scope
     FReturnType y_adj;
     ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:530:17: error: expected â;â before ây_adjâ
     FReturnType y_adj;
                 ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:532:38: error: ây_adjâ was not declared in this scope
     internal::build_y_adj(y_vi_, M_, y_adj);
                                      ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:536:26: error: expansion pattern âauto&&â contains no argument packs
         [this](auto&&... args) { this->accumulate_adjoints(args...); },
                          ^
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In lambda function:
/opt/R/3.6.2/lib/R/library/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:536:60: error: âargsâ was not declared in this scope
         [this](auto&&... args) { this->accumulate_adjoints(args...); },
                                                            ^
make: *** [stan_files/lm.o] Error 1
rm stan_files/lm.cc
ERROR: compilation failed for package ârstanarmâ
* removing â/opt/R/3.6.2/lib/R/library/rstanarmâ

The downloaded source packages are in
        â/tmp/RtmpnUS3As/downloaded_packagesâ
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("rstanarm", repos = "http://adam.oxy.com:4242/prod-cran/__linux__/centos7/latest") :
  installation of package ârstanarmâ had non-zero exit status

RStanARM Version:

2.19.3

Session info

> sessioninfo::session_info()
â Session info âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
 setting  value
 version  R version 3.6.2 (2019-12-12)
 os       Red Hat Enterprise Linux Server 7.3 (Maipo)
 system   x86_64, linux-gnu
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Chicago
 date     2020-02-15

â Packages âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
 package     * version date       lib source
 assertthat    0.2.1   2019-03-21 [1] RSPM (R 3.6.1)
 callr         3.4.2   2020-02-12 [1] RSPM (R 3.6.2)
 cli           2.0.1   2020-01-08 [1] RSPM (R 3.6.2)
 colorspace    1.4-1   2019-03-18 [1] CRAN (R 3.6.2)
 crayon        1.3.4   2017-09-16 [1] RSPM (R 3.6.2)
 dplyr         0.8.4   2020-01-31 [1] RSPM (R 3.6.2)
 fansi         0.4.1   2020-01-08 [1] RSPM (R 3.6.2)
 ggplot2     * 3.2.1   2019-08-10 [1] RSPM (R 3.6.1)
 glue          1.3.1   2019-03-12 [1] CRAN (R 3.6.2)
 gridExtra     2.3     2017-09-09 [1] RSPM (R 3.6.1)
 gtable        0.3.0   2019-03-25 [1] RSPM (R 3.6.1)
 inline        0.3.15  2018-05-18 [1] RSPM (R 3.6.1)
 lazyeval      0.2.2   2019-03-15 [1] RSPM (R 3.6.1)
 lifecycle     0.1.0   2019-08-01 [1] CRAN (R 3.6.2)
 loo           2.2.0   2019-12-19 [1] RSPM (R 3.6.2)
 magrittr      1.5     2014-11-22 [1] CRAN (R 3.6.2)
 matrixStats   0.55.0  2019-09-07 [1] RSPM (R 3.6.1)
 munsell       0.5.0   2018-06-12 [1] CRAN (R 3.6.2)
 pillar        1.4.3   2019-12-20 [1] RSPM (R 3.6.2)
 pkgbuild      1.0.6   2019-10-09 [1] RSPM (R 3.6.1)
 pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 3.6.2)
 prettyunits   1.1.1   2020-01-24 [1] RSPM (R 3.6.2)
 processx      3.4.2   2020-02-09 [1] RSPM (R 3.6.2)
 ps            1.3.1   2020-02-12 [1] RSPM (R 3.6.2)
 purrr         0.3.3   2019-10-18 [1] RSPM (R 3.6.1)
 R6            2.4.1   2019-11-12 [1] CRAN (R 3.6.2)
 Rcpp          1.0.3   2019-11-08 [1] RSPM (R 3.6.1)
 rlang         0.4.3   2020-01-24 [1] CRAN (R 3.6.2)
 rstan       * 2.19.3  2020-02-11 [1] CRAN (R 3.6.2)
 scales        1.1.0   2019-11-18 [1] CRAN (R 3.6.2)
 sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 3.6.2)
 StanHeaders * 2.19.2  2020-02-11 [1] CRAN (R 3.6.2)
 tibble        2.1.3   2019-06-06 [1] RSPM (R 3.6.1)
 tidyselect    1.0.0   2020-01-27 [1] RSPM (R 3.6.2)
 withr         2.1.2   2018-03-15 [1] RSPM (R 3.6.1)

[1] /opt/R/3.6.2/lib/R/library
bgoodri commented 4 years ago

I am guessing your C++ compiler is too old and / or does not have the C++14 flags set.

HenrikBengtsson commented 4 years ago

I can confirm that g++ 4.8.5 that comes with RHEL/CentOS 7 is too old;

$ g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you have a devtoolset Software Collection (SCL) installed on your RHEL/CentOS system, then you have access to a newer compiler, e.g.

$ scl enable devtoolset-4 "g++ --version"
g++ (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ scl enable devtoolset-6 "g++ --version"
g++ (GCC) 6.3.1 20170216 (Red Hat 6.3.1-3)
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ scl enable devtoolset-7 "g++ --version"
g++ (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I've tried, and it's sufficient to use g++ 5.3.1 to compile rstanarm on R 3.6.3 and R 4.0.0:

$ scl enable devtoolset-4 "Rscript -e 'install.packages(\"rstanarm\", repos=\"https://cloud.r-project.org\")'"

@bgoodri, I guess it's sufficient with g++ (>= 4.9.0) but I don't have access to that so I cannot test. Eitherway, I think this would be useful to add to the documentation/SystemRequirements: because there are lots of people in academia on RHEL/CentOS compute clusters out there.

leungi commented 4 years ago

@bgoodri , @HenrikBengtsson : thank you both for the feedback!

I'll try your suggestions and hope to close this ticket soon.

leungi commented 4 years ago

Wohooo 🎉

@HenrikBengtsson: works like magic! Thanks again 🙇‍♂️

leungi commented 4 years ago

For future me (and others): enable scl prior to running R or store it in /etc/profile:

atfields commented 4 years ago

FYI: gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6) from devtoolset-3 is sufficient to install rstan with the appropriate CXX14FLAGS in ~/.R/Makevars (https://github.com/stan-dev/rstan/issues/569#issuecomment-473407840), but is not sufficient to install rstanarm.