Unable to compile stan file on server

I have a stan file which compiles fine on my local laptop (Macbook, R 4.3.2, stan 2.32.2). But when I uploaded the stan file to server (I think it’s linux environment, R 4.3.1, stan 2.32.2), I couldn’t compile the file and got the following error message.

I noticed that the error message makes reference to this path: “/opt/apps/rhel8/R-4.3.1/lib64/R/lib”. However, this isn’t my R lib folder on the server. Rather it seems to be the admin’s R library folder. Instead, the other path that was also referenced is mine: “/hpc/home/ys288/R/x86_64-pc-linux-gnu-library/4.3/RcppParallel/lib/”.

One other thing I noticed is … earelier I tried to remove rstan and reinstall it. After I did remove.packages("rstan"), and then if I use system.file("libs", package = "rstan") to check, this other path “xxx/rhel8/xxx” would show up. It didn’t hinder me from re-installing rstan and properly updated my stan version though …

I’m not sure whether this caused the problem, and if so how to resolve it. Any suggestions would be greatly appreciated. Thanks!

make cmd is

>   make -f '/opt/apps/rhel8/R-4.3.1/lib64/R/etc/Makeconf' -f '/opt/apps/rhel8/R-4.3.1/lib64/R/share/make/shlib.mk' CXX='$(CXX17) $(CXX17STD)' CXXFLAGS='$(CXX17FLAGS)' CXXPICFLAGS='$(CXX17PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX17LDFLAGS)' SHLIB_LD='$(SHLIB_CXX17LD)' SHLIB='file27d1cb1e625e6c.so' OBJECTS='file27d1cb1e625e6c.o'

make would use

> g++ -std=gnu++17 -I"/opt/apps/rhel8/R-4.3.1/lib64/R/include" -DNDEBUG   -I"/admin/apps/rhel8/R-4.3.1/lib64/R/library/Rcpp/include/"  -I"/admin/apps/rhel8/R-4.3.1/lib64/R/library/RcppEigen/include/"  -I"/admin/apps/rhel8/R-4.3.1/lib64/R/library/RcppEigen/include/unsupported"  -I"/admin/apps/rhel8/R-4.3.1/lib64/R/library/BH/include" -I"/hpc/home/ys288/R/x86_64-pc-linux-gnu-library/4.3/StanHeaders/include/src/"  -I"/hpc/home/ys288/R/x86_64-pc-linux-gnu-library/4.3/StanHeaders/include/"  -I"/hpc/home/ys288/R/x86_64-pc-linux-gnu-library/4.3/RcppParallel/include/"  -I"/hpc/home/ys288/R/x86_64-pc-linux-gnu-library/4.3/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DUSE_STANC3 -DSTRICT_R_HEADERS  -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION  -D_HAS_AUTO_PTR_ETC=0  -include '/hpc/home/ys288/R/x86_64-pc-linux-gnu-library/4.3/StanHeaders/include/stan/math/prim/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1   -I/opt/apps/rhel8/bzip2-1.0.8/include    -fpic  -g -O2  -c file27d1cb1e625e6c.cpp -o file27d1cb1e625e6c.o
> if test  "zfile27d1cb1e625e6c.o" != "z"; then \
>   echo g++ -std=gnu++17 -shared -L"/opt/apps/rhel8/R-4.3.1/lib64/R/lib" -L/opt/apps/rhel8/bzip2-1.0.8/lib -o file27d1cb1e625e6c.so file27d1cb1e625e6c.o  '/hpc/home/ys288/R/x86_64-pc-linux-gnu-library/4.3/rstan/lib//libStanServices.a' -L'/hpc/home/ys288/R/x86_64-pc-linux-gnu-library/4.3/StanHeaders/lib/' -lStanHeaders -L'/hpc/home/ys288/R/x86_64-pc-linux-gnu-library/4.3/RcppParallel/lib/' -ltbb   -L"/opt/apps/rhel8/R-4.3.1/lib64/R/lib" -lR; \
>   g++ -std=gnu++17 -shared -L"/opt/apps/rhel8/R-4.3.1/lib64/R/lib" -L/opt/apps/rhel8/bzip2-1.0.8/lib -o file27d1cb1e625e6c.so file27d1cb1e625e6c.o  '/hpc/home/ys288/R/x86_64-pc-linux-gnu-library/4.3/rstan/lib//libStanServices.a' -L'/hpc/home/ys288/R/x86_64-pc-linux-gnu-library/4.3/StanHeaders/lib/' -lStanHeaders -L'/hpc/home/ys288/R/x86_64-pc-linux-gnu-library/4.3/RcppParallel/lib/' -ltbb   -L"/opt/apps/rhel8/R-4.3.1/lib64/R/lib" -lR; \
> fi
> Error in compileCode(f, code, language = language, verbose = verbose) : 
>   /admin/apps/rhel8/R-4.3.1/lib64/R/library/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:654:74: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<double>::type’ {aka ‘__m128d’} [-Wignored-attributes]  654 |   return internal::first_aligned<int(unpacket_traits<DefaultPacketType>::alignment),Derived>(m);      |                                                                          ^~~~~~~~~g++: fatal error: Killed signal terminated program cc1pluscompilation terminated.make: *** [/opt/apps/rhel8/R-4.3.1/lib64/R/etc/Makeconf:200: file27d1cb1e625e6c.o] Error 1
> Error in sink(type = "output") : invalid connection

I’m not sure how to solve the server problem with rstan from what you reported—@bgoodri might know. If you really need to get it installed, then you should log onto the server and step through the rstan installation instructions step by step and make sure all the diagnostics work, like running C++, etc. Then report back on the first place it fails.

I’d pay particular attention to the C++ toolchain being configured properly, which requires a click through.

Alternatively, you might try cmdstanr, which has fewer dependencies and is easier to install because Stan runs outside of R. That way, you install cmdstan and then have a very lightweight R wrapper where R doesn’t have to do binary communication with Stan.

Thanks for your reply!!

Um… I was able to install RStan on server. And I was even able to compile other projects and run stuff there as well. So I always thought the installation was fine. But I’ll go through the RStan installation instructions step by step to see whether I’ve missed anything!

A colleague of mine also suggested creating a conda R environment on server and run RStan there. I’ll also give that a go.

I tried a few different things, but long story short … I got rstan to compile after updating Rcpp package in R.

CmdStanR looks like another pretty nice way to work with stan. Will give it a go next time.

1 Like