Compilation error RSTAN

Dear RSTAN community,

I’m running into compilation errors when calling a model through brms on my institute’s cluster. Any hints much appreciated!

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
              instantiation of "T__ modela3e1f19e59e_1bcd7d12e8e907f753fd6fd08f4500ed_namespace::modela3e1f19e59e_1bcd7d12e8e907f753fd6fd08f4500ed::log_prob<propto__,jacobian__,T__>(std::vector<T__, std::allocator<T__>> &, std::vector<int, std::allocator<int>> &, std::ostream *) const [with propto__=false, jacobian__=false, T__=stan::math::var]" at line 950 of "filea3e113e2ecaa.cpp"            instantiation of "T_ modela3e1f19e59e_1bcd7d12e8e907f753fd6fd08f4500ed_namespace::modela3e1f19e59e_1bcd7d12e8e907f753fd6fd08f4500ed::log_prob<propto,jacobian,T_>(Eigen::Matrix<T_, -1, 1, 0, -1, 1> &, std::ostream *) const [with propto=false, jacobian=false, T_=stan::math::var]" at line 96 of "/p/projects/rd3mod/R/libraries/3.6.3/StanHeaders/include/src/stan/model/model_base_crtp.hpp"            instantiation of "stan::math::var stan::model::model_base_crtp<M>::log_prob(Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> &, std::ostream *) const [with M=modela3e1f19e59e_1bcd7d12e8e907f753fd6fd

  • Operating System: SUSE Linux Enterprise Server Version 12, Release Level 3
  • R version: 3.6.3
  • rstan version: 2.21.2
  • brms Version: 2.15

Sorry about the delay in getting to this. A common issue with running Stan on clusters is that the install c++ compiler can be too outdated for some of the features that we need. You can check this by running:

system("g++ -v")
system("clang++ -v")

Stan requires g++ >= 4.9.3 or clang++ >= 6.0

Thanks for the reply, no problem about the delay!

running system("g++ -v") gives me:

gcc version 7.3.0 (GCC)

This is the same as g++ , or am I mistaken?

Hmm, so that looks like your compiler is more than recent enough for Stan. There can be some incompatibility/instability between RStan and R3.6.x, so for this I’d recommend installing cmdstanr and using that for the brms models.

For this, you just need to install cmdstanr & cmdstan using the steps here: Getting started with CmdStanR • cmdstanr

Then you can add backend = 'cmdstanr' to your brm call

Hey Andrew!

cmdstanr compiles and is now sampling, super cool thank you!

Don’t know if you are directly involved with the CmdStanR folks but just wanted to note that with the default instructions on the website I got:


> install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
Installing package into ‘/p/projects/rd3mod/R/libraries/3.6.3’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository https://mc-stan.org/r-packages/src/contrib:
  cannot open URL 'https://mc-stan.org/r-packages/src/contrib/PACKAGES'
Warning message:
package ‘cmdstanr’ is not available (for R version 3.6.3)

But I could install cmdstanr with install_github

Hm that’s odd, it might be a firewall or network config issue? Not sure since it works for me locally