I am using R on the Centos7 cluster, and successfully installed all the required packages including rstan and cmdstanr. First loaded the required modules:
module load gcc/8.3.0
module load R/4.0.3
module load gsl/2.6
R
and installed the required packages succesfully, and I tried the following models:
library(cmdstanr)
stan_program <- write_stan_tempfile("
parameters {
real x;
}
model {
real mu = -2;
x ~ normal(fabs(mu), 1);
}
"
)
mod <- cmdstan_model(stan_program)
fit <- mod$sample()
both of them worked fine and didn’t get any error. After all, I am trying to submit the job with bash script, but getting this compilation error.
mod <- cmdstan_model('model3.stan')
Compiling Stan program...
In file included from /share/builds/spack-compilers/opt/spack/linux-centos7-sandybridge/gcc-8.3.1/gcc-8.3.0-mnwujmnexs6zvenuhlu5m4io2om4sg55/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/c++config.h:508,
from /share/builds/spack-compilers/opt/spack/linux-centos7-sandybridge/gcc-8.3.1/gcc-8.3.0-mnwujmnexs6zvenuhlu5m4io2om4sg55/include/c++/8.3.0/new:39,
from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Core:82,
from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Dense:1,
from stan/lib/stan_math/stan/math/prim/fun/Eigen.hpp:22,
from stan/lib/stan_math/stan/math/rev.hpp:4,
from stan/lib/stan_math/stan/math.hpp:19,
from stan/src/stan/model/model_header.hpp:4,
from /tmp/RtmpDzWg2n/model-5a62383c457c.hpp:3:
/share/builds/spack-compilers/opt/spack/linux-centos7-sandybridge/gcc-8.3.1/gcc-8.3.0-mnwujmnexs6zvenuhlu5m4io2om4sg55/include/c++/8.3.0/x86_64-pc-linux-gnu/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
compilation terminated.
make: *** [/tmp/RtmpDzWg2n/model-5a62383c457c] Error 1
Error: An error occured during compilation! See the message above for more information.
Execution halted
If anybody can help with this, I would really appreciate it.
Hi,
so one possible reason is that in the job, you have a differently set environment (path or other environmental variables), could you check if the env variables are the same?
Thank you for your response. HPC that I’ve been using primarily running two types of jobs: batch and interactive. Stan model compiling on interactive queue but when I submit it as a batch job having the same error. Could you please let me know, how can I check the environmental variables? Thanks!
is not a supported compiler on Linux according to 1 CmdStan Installation | CmdStan User’s Guide. I got cmdstanr to work on a Centos 7 cluster easily by following the conda installation in that link, installing CmdStan and the C++ compiler with
conda create -n stan-env -c conda-forge cmdstan
and then before submitting a batch script activate the environment with
conda activate stan-env
Then the cmdstanr startup message says - CmdStan path set to: ~/.conda/envs/stan-env/bin/cmdstan
First of all, thank you so much for the help. I was using the conda env also, and I tried your suggestions. Usually at the beginning I was loading modules like gsl and gcc. This time I did not load gcc/8.3.1 module:
(Also tried to activate stan env inside the bash script but got the same error)
After submitting the bash script, it provided following error:
mod <- cmdstanr::cmdstan_model('dglnrt_re_conda.stan')
g++: error: unrecognized command line option ‘-std=c++17’
g++: error: unrecognized command line option ‘-fno-plt’
make: *** [make/program:58: /tmp/RtmpcNfKSF/model-6f24490dc687] Error 1
Error: An error occured during compilation! See the message above for more information.
Execution halted
Not#1: When I load older gcc modules (4.7.3 or 5.5.0), I am having the same compilation error.
Not#2: When I load gcc/8.3.1, I am getting the features.h error.
It is not invoked by activation but library(cmdstanr) in your R script and will go to output (cmd_stan.%J.out).
You are activating a different conda environment that stan-env here. I don’t have any conda commands
in the batch script, only module load R/ver where ver is the R version to which I have installed cmdstanr.
mod <- cmdstanr::cmdstan_model('dglnrt_re_conda.stan')
g++: error: unrecognized command line option ‘-std=c++17’
g++: error: unrecognized command line option ‘-fno-plt’
make: *** [make/program:58: /tmp/RtmpcNfKSF/model-6f24490dc687] Error 1
Error: An error occured during compilation! See the message above for more information.
Execution halted