Reputation: 49
fresh new install of ubuntu 18.04. -> ok
R 3.5.0 installed from this repo:
deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/
with secure apt key added by:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
R installed correctly and working even launched from rstudio.
Trying to install TMB
library, installation command from R console or terminal R in super user mode with this command (tried both and removed one before trying the second, so no possible conflict between user libraries and R libraries):
install.packages("TMB",type = "source")
the installation starts, it install dependant packages (Rcpp,RcppEigen etcetera).
during the installation/compiling of exactly RcppEigen the console starts to kicks like 10000 line of warnings (like if is missing some compiler link), this is the first line of which it deviates from normal installation:
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (Rcpp)
* installing *source* package ‘RcppEigen’ ...
** package ‘RcppEigen’ successfully unpacked and MD5 sums checked
** libs
g++ -I"/usr/share/R/include" -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fpic -g -O2 -fdebug-prefix-map=/build/r-base-O3QT2W/r-base-3.5.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppEigen.cpp -o RcppEigen.o
In file included from ../inst/include/Eigen/Core:388:0,
from ../inst/include/Eigen/Dense:1,
from ../inst/include/RcppEigenForward.h:30,
from ../inst/include/RcppEigen.h:25,
from RcppEigen.cpp:22:
../inst/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 }; };
^
../inst/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 }; };
^
../inst/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 }; };
^
../inst/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; };
these are the last lines of the install.package("TMB") command:
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<double>::type {aka __vector(4) double}’ [-Wignored-attributes]
>::type PacketReturnType;
^~~~~~~~~~~~~~~~
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h: In instantiation of ‘class Eigen::DenseCoeffsBase<Eigen::Transpose<const Eigen::Block<const Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, -1, false>, 1, -1, false> >, 0>’:
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:478:7: required from ‘class Eigen::DenseCoeffsBase<Eigen::Transpose<const Eigen::Block<const Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, -1, false>, 1, -1, false> >, 2>’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/DenseBase.h:41:34: required from ‘class Eigen::DenseBase<Eigen::Transpose<const Eigen::Block<const Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, -1, false>, 1, -1, false> > >’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/MatrixBase.h:48:34: required from ‘class Eigen::MatrixBase<Eigen::Transpose<const Eigen::Block<const Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, -1, false>, 1, -1, false> > >’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/Transpose.h:115:37: required from ‘class Eigen::TransposeImpl<const Eigen::Block<const Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, -1, false>, 1, -1, false>, Eigen::Dense>’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/Transpose.h:52:37: required from ‘class Eigen::Transpose<const Eigen::Block<const Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, -1, false>, 1, -1, false> >’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/ProductEvaluators.h:552:40: [ skipping 22 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/PlainObjectBase.h:816:7: required from ‘void Eigen::PlainObjectBase<Derived>::_init1(const Eigen::DenseBase<ElseDerived>&) [with T = Eigen::Inverse<Eigen::Matrix<double, -1, -1> >; OtherDerived = Eigen::Inverse<Eigen::Matrix<double, -1, -1> >; Derived = Eigen::Matrix<double, -1, -1>]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/Matrix.h:296:31: required from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T&) [with T = Eigen::Inverse<Eigen::Matrix<double, -1, -1> >; _Scalar = double; int _Rows = -1; int _Cols = -1; int _Options = 0; int _MaxRows = -1; int _MaxCols = -1]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/TMB/include/tmbutils/vector.hpp:93:22: required from ‘tmbutils::matrix<Type>::matrix(T1) [with T1 = Eigen::Inverse<Eigen::Matrix<double, -1, -1> >; Type = double]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/TMB/include/expm.hpp:36:14: required from ‘atomic::Block<Type> atomic::Block<Type>::inverse() [with Type = double]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/TMB/include/expm.hpp:180:17: required from ‘matrix_pade atomic::expm(matrix_pade) [with matrix_pade = atomic::nestedTriangle<0>]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/TMB/include/expm.hpp:192:52: required from here`
the last line of output from install.packages("TMB",type="source") is:
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o simple.so simple.o -L/usr/lib/R/lib -lR
Build time 16.121 seconds
* DONE (TMB)
the installation seems to finish (console gives * DOME(TMB) at the end), but running a basic example of TMB (linear regression) gives fatal R session error.
example in R code:
tmb_model <- "
// linear regression
#include <TMB.hpp>
template<class Type>
Type objective_function<Type>::operator() () {
// data:
DATA_VECTOR(x);
DATA_VECTOR(y);
// parameters:
PARAMETER(a); // intercept
PARAMETER(b); // slope
PARAMETER(log_sigma); // log(residual SD)
// we fit sigma on a log scale to keep it > 0
// procedures: (transformed parameters)
Type sigma = exp(log_sigma);
int n = y.size(); // get number of data points to loop over
Type nll = 0.0; // initialize negative log likelihood
for(int i = 0; i < n; i++){ // C++ starts loops at 0!
// get negative log likelihood (last argument is log = TRUE)
nll -= dnorm(y[i], a + b * x[i], sigma, true);
}
return nll;
}"
write(tmb_model, file = "regression.cpp")
library(TMB)
compile("regression.cpp")
using TMB::compile gives tons of warnings (these are the last worning + gcc line output):
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<double>::type {aka __vector(4) double}’ [-Wignored-attributes]
>::type PacketReturnType;
^~~~~~~~~~~~~~~~
In file included from /home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/Core:436:0,
from /home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/Dense:1,
from /home/alberto/R/x86_64-pc-linux-gnu-library/3.5/TMB/include/TMB.hpp:53,
from regression.cpp:3:
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h: In instantiation of ‘struct Eigen::internal::evaluator<Eigen::Block<const Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >, 1, -1, false> >’:
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/AssignEvaluator.h:730:20: required from ‘void Eigen::internal::call_dense_assignment_loop(DstXprType&, const SrcXprType&, const Functor&) [with DstXprType = Eigen::Block<Eigen::Matrix<double, -1, -1>, 1, -1, false>; SrcXprType = Eigen::Block<const Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >, 1, -1, false>; Functor = Eigen::internal::assign_op<double, double>]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/AssignEvaluator.h:879:31: required from ‘static void Eigen::internal::Assignment<DstXprType, SrcXprType, Functor, Eigen::internal::Dense2Dense, Weak>::run(DstXprType&, const SrcXprType&, const Functor&) [with DstXprType = Eigen::Block<Eigen::Matrix<double, -1, -1>, 1, -1, false>; SrcXprType = Eigen::Block<const Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >, 1, -1, false>; Functor = Eigen::internal::assign_op<double, double>; Weak = void]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/AssignEvaluator.h:836:49: required from ‘void Eigen::internal::call_assignment_no_alias(Dst&, const Src&, const Func&) [with Dst = Eigen::Block<Eigen::Matrix<double, -1, -1>, 1, -1, false>; Src = Eigen::Block<const Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >, 1, -1, false>; Func = Eigen::internal::assign_op<double, double>]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/AssignEvaluator.h:804:27: required from ‘void Eigen::internal::call_assignment(Dst&, const Src&, const Func&, typename Eigen::internal::enable_if<(! Eigen::internal::evaluator_assume_aliasing<Src>::value), void*>::type) [with Dst = Eigen::Block<Eigen::Matrix<double, -1, -1>, 1, -1, false>; Src = Eigen::Block<const Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >, 1, -1, false>; Func = Eigen::internal::assign_op<double, double>; typename Eigen::internal::enable_if<(! Eigen::internal::evaluator_assume_aliasing<Src>::value), void*>::type = void*]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/AssignEvaluator.h:782:18: required from ‘void Eigen::internal::call_assignment(Dst&, const Src&) [with Dst = Eigen::Block<Eigen::Matrix<double, -1, -1>, 1, -1, false>; Src = Eigen::Block<const Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >, 1, -1, false>]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/Assign.h:66:28: [ skipping 26 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/PlainObjectBase.h:816:7: required from ‘void Eigen::PlainObjectBase<Derived>::_init1(const Eigen::DenseBase<ElseDerived>&) [with T = Eigen::Inverse<Eigen::Matrix<double, -1, -1> >; OtherDerived = Eigen::Inverse<Eigen::Matrix<double, -1, -1> >; Derived = Eigen::Matrix<double, -1, -1>]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/Matrix.h:296:31: required from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T&) [with T = Eigen::Inverse<Eigen::Matrix<double, -1, -1> >; _Scalar = double; int _Rows = -1; int _Cols = -1; int _Options = 0; int _MaxRows = -1; int _MaxCols = -1]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/TMB/include/tmbutils/vector.hpp:93:22: required from ‘tmbutils::matrix<Type>::matrix(T1) [with T1 = Eigen::Inverse<Eigen::Matrix<double, -1, -1> >; Type = double]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/TMB/include/expm.hpp:36:14: required from ‘atomic::Block<Type> atomic::Block<Type>::inverse() [with Type = double]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/TMB/include/expm.hpp:180:17: required from ‘matrix_pade atomic::expm(matrix_pade) [with matrix_pade = atomic::nestedTriangle<0>]’
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/TMB/include/expm.hpp:192:52: required from here
/home/alberto/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:960:8: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<double>::type {aka __vector(4) double}’ [-Wignored-attributes]
enum {
^
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o regression.so regression.o -L/usr/lib/R/lib -lR
[1] 0
During execution of this R code it gives me immediately fatal error on rstudio (R console), exactly taken from TMB examples:
set.seed(123)
x <- runif(20, 1, 10)
y <- rnorm(20, mean = 1.8 + 2.4 * x, sd = exp(0.3))
plot(x, y)
obj <- MakeADFun(
data = list(x = x, y = y),
parameters = list(a = 0, b = 0, log_sigma = 0),
DLL = "regression")
opt <- nlminb(start = obj$par, obj = obj$fn, gr = obj$gr)
rep <- sdreport(obj)
compiler:
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-16ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --with-as=/usr/bin/x86_64-linux-gnu-as --with-ld=/usr/bin/x86_64-linux-gnu-ld --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)
~.R/Makevars (something touched before for RcppArmadillo, maybe it is my fault and the error is here on CXXFLAGS):
CFLAGS= -O -mtune=native
CXXFLAGS= -O2 -mtune=native -march=native -pthread -fopenmp $(BLAS_LIBS) $(LAPACK_LIBS)
FFLAGS=-g -O -mtune=native
FCFLAGS=-g -O -mtune=native
Edit(myself)
I try the RcppEigen example at: http://dirk.eddelbuettel.com/code/rcpp.eigen.html
it runs ok, pushing many warnings (that normally don't occur with Rcpp), calling sourceCpp(file="input.cc")
, it compile and execute correctly.
I try the first example found on TMB at https://github.com/nwfsc-assess/geostatistical_delta-GLMM/wiki/Steps-to-install-TMB it gives me :
0 regions found.
Using 8 threads
TMB has received an error from Eigen. The following condition was not met:
index >= 0 && index < size()
Please check your matrix-vector bounds etc., or run your program through a debugger.
before crashing
Upvotes: 0
Views: 877
Reputation: 49
solved:
1) to avoid noisy warnings output, add the flag
-Wno-ignored-attributes
2) to avoid runtime error on adfun call, remove the flag
-fopenmp
before compiling the objective function IF the model (C++ code of objective_function<Type>::operator()
) doesn't use openMP (example #pragma omp
something).
source (I ask here): https://github.com/kaskr/adcomp/issues/277
Upvotes: 0
Reputation: 1087
looks like you may not have the Eigen dev package installed (since is it is fresh ubuntu install) Have you tried
sudo apt-get install libeigen3-dev
looks like you can also install precompiled binary the package via
sudo apt-get install r-cran-rcppeigen
apparently rcppeigen may require a lot of ram to compile and fails on some machines with little ram.
Upvotes: 0