Problem
I am trying to run the code/model from this project https://github.com/ImperialCollegeLondon/covid19model. They provide a conda environment.yml
file which I used to create an environment containing R, Stan and dependencies, but the environment isn’t working for me.
I have looked at other posts referring to similar error messages, and found information that has helped me investigate, but I have not yet found the solution to my problem.
I used information in one of the other posts to start trying to get a basic Stan model to run, but even this isn’t working:
m <- stan_model(model_code = 'parameters {real y;} model {y ~ normal(0,1);}',
obfuscate_model_name = FALSE)
The output I get is:
Warning message in system(cmd, intern = !verbose):
“running command '/opt/conda/lib/R/bin/R CMD SHLIB file662e54cea2.cpp 2> file662e54cea2.cpp.err.txt' had status 1”
Error in compileCode(f, code, language = language, verbose = verbose): Compilation ERROR, function(s)/method(s) not created! file662e54cea2.cpp:6:36: warning: ISO C++11 requires whitespace after the macro name
#define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
^
In file included from /opt/conda/lib/R/library/RcppEigen/include/Eigen/Core:383:0,
from /opt/conda/lib/R/library/RcppEigen/include/Eigen/Dense:1,
from /opt/conda/lib/R/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
from <command-line>:0:
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:60:39: warning: ignoring attributes on template argument '__m128 {aka __vector(4) float}' [-Wignored-attributes]
template<> struct is_arithmetic<__m128> { enum { value = true }; };
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:61:40: warning: ignoring attributes on template argument '__m128i {aka __vector(2) long long int}' [-Wignored-attributes]
template<> struct is_arithmetic<__m128i> { enum { value = true }; };
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:62:40: warning: ignoring attributes on template argument '__m128d {aka __vector(2) double}' [-Wignored-attributes]
template<> struct is_arithmetic<__m128d> { enum { value = true }; };
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:161:43: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f {aka __vector(4) float}' [-Wignored-attributes]
template<> struct unpacket_traits<Packet4f> { typedef float type; enum {size=4, alignment=Aligned16}; typedef Packet4f half; };
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:162:43: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d {aka __vector(2) double}' [-Wignored-attributes]
template<> struct unpacket_traits<Packet2d> { typedef double type; enum {size=2, alignment=Aligned16}; typedef Packet2d half; };
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:163:43: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i {aka __vector(2) long long int}' [-Wignored-attributes]
template<> struct unpacket_traits<Packet4i> { typedef int type; enum {size=4, alignment=Aligned16}; typedef Packet4i half; };
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:687:35: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f {aka __vector(4) float}' [-Wignored-attributes]
struct palign_impl<Offset,Packet4f>
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:697:35: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i {aka __vector(2) long long int}' [-Wignored-attributes]
struct palign_impl<Offset,Packet4i>
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:707:35: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d {aka __vector(2) double}' [-Wignored-attributes]
struct palign_impl<Offset,Packet2d>
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:778:34: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f {aka __vector(4) float}' [-Wignored-attributes]
ptranspose(PacketBlock<Packet4f,4>& kernel) {
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:783:34: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d {aka __vector(2) double}' [-Wignored-attributes]
ptranspose(PacketBlock<Packet2d,2>& kernel) {
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:790:34: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i {aka __vector(2) long long int}' [-Wignored-attributes]
ptranspose(PacketBlock<Packet4i,4>& kernel) {
^
In file included from /opt/conda/lib/R/library/RcppEigen/include/Eigen/Core:374:0,
from /opt/conda/lib/R/library/RcppEigen/include/Eigen/Dense:1,
from /opt/conda/lib/R/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
from <command-line>:0:
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/Default/ConjHelper.h:15:70: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f {aka __vector(4) float}' [-Wignored-attributes]
template<> struct conj_helper<PACKET_REAL, PACKET_CPLX, false,false> { \
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/Complex.h:232:1: note: in expansion of macro 'EIGEN_MAKE_CONJ_HELPER_CPLX_REAL'
EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet2cf,Packet4f)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/Default/ConjHelper.h:22:70: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f {aka __vector(4) float}' [-Wignored-attributes]
template<> struct conj_helper<PACKET_CPLX, PACKET_REAL, false,false> { \
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/Complex.h:232:1: note: in expansion of macro 'EIGEN_MAKE_CONJ_HELPER_CPLX_REAL'
EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet2cf,Packet4f)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/Default/ConjHelper.h:15:70: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d {aka __vector(2) double}' [-Wignored-attributes]
template<> struct conj_helper<PACKET_REAL, PACKET_CPLX, false,false> { \
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/Complex.h:417:1: note: in expansion of macro 'EIGEN_MAKE_CONJ_HELPER_CPLX_REAL'
EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet1cd,Packet2d)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/Default/ConjHelper.h:22:70: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d {aka __vector(2) double}' [-Wignored-attributes]
template<> struct conj_helper<PACKET_CPLX, PACKET_REAL, false,false> { \
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/Complex.h:417:1: note: in expansion of macro 'EIGEN_MAKE_CONJ_HELPER_CPLX_REAL'
EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet1cd,Packet2d)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/conda/lib/R/library/RcppEigen/include/Eigen/Core:386:0,
from /opt/conda/lib/R/library/RcppEigen/include/Eigen/Dense:1,
from /opt/conda/lib/R/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
from <command-line>:0:
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/AVX/PacketMath.h:35:39: warning: ignoring attributes on template argument '__m256 {aka __vector(8) float}' [-Wignored-attributes]
template<> struct is_arithmetic<__m256> { enum { value = true }; };
^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/AVX/PacketMath.h:36:40: warning: ignoring attributes on template argument '__m256i {aka __vector(4) long long int}' [-Wignored-attributes]
template<> struct is_arithmetic<__m256i> { enum { value = true }; };
Traceback:
1. stan_model(model_code = "parameters {real y;} model {y ~ normal(0,1);}",
. obfuscate_model_name = FALSE)
2. cxxfunctionplus(signature(), body = paste(" return Rcpp::wrap(\"",
. model_name, "\");", sep = ""), includes = inc, plugin = "rstan",
. save_dso = save_dso | auto_write, module_name = paste("stan_fit4",
. model_cppname, "_mod", sep = ""), verbose = verbose)
3. pkgbuild::with_build_tools(cxxfunction(sig = sig, body = body,
. plugin = plugin, includes = includes, settings = settings,
. ..., verbose = verbose), required = rstan_options("required") &&
. !identical(Sys.getenv("WINDOWS"), "TRUE") && !identical(Sys.getenv("R_PACKAGE_SOURCE"),
. ""))
4. cxxfunction(sig = sig, body = body, plugin = plugin, includes = includes,
. settings = settings, ..., verbose = verbose)
5. compileCode(f, code, language = language, verbose = verbose)
6. stop(paste("Compilation ERROR, function(s)/method(s) not created!",
. paste(errmsg, collapse = "\n")))
Error in sink(type = "output"): invalid connection
Traceback:
1. stan_model(model_code = "parameters {real y;} model {y ~ normal(0,1);}",
. obfuscate_model_name = FALSE)
2. cxxfunctionplus(signature(), body = paste(" return Rcpp::wrap(\"",
. model_name, "\");", sep = ""), includes = inc, plugin = "rstan",
. save_dso = save_dso | auto_write, module_name = paste("stan_fit4",
. model_cppname, "_mod", sep = ""), verbose = verbose)
3. sink(type = "output")
As mentioned in the beginning of the long error message, the C++ code that is emitted by Stan doesn’t look entirely right to my eyes. In particular, it includes this line:
#define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
Libraries
packageVersion("BH"): ‘1.72.0.3’
pkgbuild::has_build_tools(debug = TRUE)
works and returns TRUE along with this console logging:
Running /opt/conda/lib/R/bin/R CMD SHLIB foo.c
x86_64-conda_cos6-linux-gnu-cc -I"/opt/conda/lib/R/include" -DNDEBUG -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /opt/conda/include -I/opt/conda/include -Wl,-rpath-link,/opt/conda/lib -fpic -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /opt/conda/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/r-base_1585837569147/work=/usr/local/src/conda/r-base-3.6.3 -fdebug-prefix-map=/opt/conda=/usr/local/src/conda-prefix -c foo.c -o foo.o
x86_64-conda_cos6-linux-gnu-cc -shared -L/opt/conda/lib/R/lib -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/opt/conda/lib -Wl,-rpath-link,/opt/conda/lib -L/opt/conda/lib -Wl,-rpath-link,/opt/conda/lib -o foo.so foo.o -L/opt/conda/lib/R/lib -lR
Operating System: Ubuntu 18.04.4 LTS
Interface Version: packageVersion("rstan"): ‘2.19.3’
Compiler/Toolkit: gcc --version: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Any tips or pointers would be greatly appreciated. Thanks!