Compilation error, rstan on HPC

I am trying to do within-chain parallelization with brm models which requires cmdstanr as backend
but I cannot make it run on HPC, getting the following errors.

> m1<- brm(predictedRT~Factor1*(Factor2+Factor3)+(1+Factor1*(Factor2+Factor3)||participant)+(1+Factor1*(Factor2+Factor3)||item),
+          iter=2000,
+          chains=4,
+          cores=16,
+          control=list(max_treedepth=15),backend = "cmdstanr",threads = threading(4),prior = prior1)

stan/src/stan/model/model_header.hpp:4:10: fatal error: stan/math.hpp: No such file or directory
    4 | #include <stan/math.hpp>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
src/cmdstan/main.cpp:1:10: fatal error: cmdstan/command.hpp: No such file or directory
    1 | #include <cmdstan/command.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [make/program:14: src/cmdstan/main_threads.o] Error 1
Error: An error occured during compilation! See the message above for more information.
Execution halted

R Version : 4.1

  • brms Version: 2.15.0

I also have tried reinstall these packages

install.packages(“Rccp”,repos = “”)
install.packages(“RcppEigen”,repos = “”)
install.packages(“StanHeaders”,repos = “”)
install.packages(“rstan”,repos = “”)

And this is my directory

system.file(“include”, “stan”, “math”, “prim”, “mat”, “fun”, “Eigen.hpp”, package = “StanHeaders”)
[1] “/home/kh3686/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp”
[1] “/home/kh3686/R/x86_64-pc-linux-gnu-library/4.1”
[2] “/usr/local/lib/R/library”



You are using cmdstanr backend but installed only rstan. The grief is that cmdstan and math files are missing. You can install cmdstanr, use its install_cmdstan command to install cmdstan.

Thank you so much.
I remembered to do this when using my local computer but when I switched to HPC I forgot about this.
I was also having trouble install cmdstan because there’re just too many files in this package and my disc quota is exceeded. But in the end I made it work. Thank you very much.