Closed shug3502 closed 5 years ago
You should be able to set CXXFLAGS
and other environmental in the Makevars
file. On linux, this should be in the directory .R
. Could you try creating a file .R/Makevars
with a line CXXFLAGS=-std=c++11
? Alternatively, set CXXFLAGS
in the shell that you start R from, or in a startup shell script.
I recently installed Libbi and RBi on a Linux machine, but have had some problems sampling from models with RBi. Minimal code here: https://gist.github.com/shug3502/8bb72b66ac341e5859a9101d9a8b9024 The error occurs when trying to sample from the posterior in the final line (error message pasted below). I get the same kind of error when using LibBi directly. I can fix it by manually adding '-std=c++11' to CXXFLAGS in the Makefile when using LibBi. When using RBi, I don't know how to add this to the CXXFLAGS. Any suggestions about how to fix this? Thanks! (Additionally it looks like the same error may be present when the code for the rbi.helpers vignette was run? https://cran.r-project.org/web/packages/rbi.helpers/vignettes/introduction.html )
/usr/local/bin/libbi sample --seed 52857484 --nsamples 1000 --end-time 112 --noutputs 16 --obs-file /tmp/RtmpkB8HgN/SIR6c53e406f0f75/SIR_obs6c53e7ea7ee2b.nc --init-file /tmp/RtmpkB8HgN/SIR6c53e406f0f75/SIR_init6c53e36d1405.nc --target posterior --nparticles 32 --verbose --output-file /tmp/RtmpkB8HgN/SIR6c53e406f0f75/SIR_output6c53e55326ed8.nc --model-file /tmp/RtmpkB8HgN/SIR6c53e406f0f75/SIR.bi Parsing... Processing arguments... Transforming model... Generating Doxyfile... Generating C++ code... Generating GNU autotools build system... make -j 4 sample_cpu Building... depbase=&, ForwardIterator, ForwardIterator, BinaryPredicate) [with DerivedPolicy = thrust::system::omp::detail::tag; ForwardIterator = thrust::detail::normal_iterator<const double>; BinaryPredicate = bi::nan_less_functor]’:
/usr/local/cuda/include/thrust/system/omp/detail/extrema.h:39:54: required from ‘ForwardIterator thrust::system::omp::detail::max_element(thrust::system::omp::detail::execution_policy&, ForwardIterator, ForwardIterator, BinaryPredicate) [with DerivedPolicy = thrust::system::omp::detail::tag; ForwardIterator = thrust::detail::normal_iterator<const double >; BinaryPredicate = bi::nan_less_functor]’
/usr/local/cuda/include/thrust/detail/extrema.inl:65:21: required from ‘ForwardIterator thrust::max_element(const thrust::detail::execution_policy_base&, ForwardIterator, ForwardIterator, BinaryPredicate) [with DerivedPolicy = thrust::system::omp::detail::tag; ForwardIterator = thrust::detail::normal_iterator<const double>; BinaryPredicate = bi::nan_less_functor]’
/usr/local/cuda/include/thrust/detail/extrema.inl:139:29: required from ‘ForwardIterator thrust::max_element(ForwardIterator, ForwardIterator, BinaryPredicate) [with ForwardIterator = thrust::detail::normal_iterator<const double >; BinaryPredicate = bi::nan_less_functor]’
src/bi/state/../primitive/vector_primitive.hpp:867:32: required from ‘typename V1::value_type bi::max_reduce(V1) [with V1 = bi::host_vector_reference; typename V1::value_type = double]’
src/bi/state/../primitive/vector_primitive.hpp:936:21: required from ‘typename V1::value_type bi::logsumexp_reduce(V1) [with V1 = bi::host_vector_reference; typename V1::value_type = double]’
src/bi/filter/BootstrapPF.hpp:193:37: required from ‘void bi::BootstrapPF<B, F, O, R>::term(S1&) [with S1 = bi::BootstrapPFState<ModelSIR, (bi::Location)0u>; B = ModelSIR; F = bi::Forcer<bi::InputNullBuffer, (bi::Location)0u>; O = bi::Observer<bi::InputNetCDFBuffer, (bi::Location)0u>; R = bi::Resampler]’
src/bi/filter/Filter.hpp:68:3: required from ‘void bi::Filter::filter(bi::Random&, bi::ScheduleIterator, bi::ScheduleIterator, S1&, IO1&) [with S1 = bi::BootstrapPFState<ModelSIR, (bi::Location)0u>; IO1 = bi::ParticleFilterBuffer<bi::BootstrapPFCache<(bi::Location)0u> >; F = bi::BootstrapPF<ModelSIR, bi::Forcer<bi::InputNullBuffer, (bi::Location)0u>, bi::Observer<bi::InputNetCDFBuffer, (bi::Location)0u>, bi::Resampler >; bi::ScheduleIterator = gnu_cxx::__normal_iterator<const bi::ScheduleElement*, std::vector >]’
src/bi/sampler/MarginalMH.hpp:222:3: required from ‘void bi::MarginalMH<B, F>::init(bi::Random&, bi::ScheduleIterator, bi::ScheduleIterator, S1&, IO1&, IO2&) [with S1 = bi::BootstrapPFState<ModelSIR, (bi::Location)0u>; IO1 = bi::ParticleFilterBuffer<bi::BootstrapPFCache<(bi::Location)0u> >; IO2 = bi::InputNetCDFBuffer; B = ModelSIR; F = bi::Filter<bi::BootstrapPF<ModelSIR, bi::Forcer<bi::InputNullBuffer, (bi::Location)0u>, bi::Observer<bi::InputNetCDFBuffer, (bi::Location)0u>, bi::Resampler > >; bi::ScheduleIterator = gnu_cxx::normal_iterator<const bi::ScheduleElement*, std::vector >]’
src/bi/sampler/MarginalMH.hpp:204:7: required from ‘void bi::MarginalMH<B, F>::sample(bi::Random&, bi::ScheduleIterator, bi::ScheduleIterator, S1&, int, IO1&, IO2&) [with S1 = bi::MarginalMHState<ModelSIR, (bi::Location)0u, bi::BootstrapPFState<ModelSIR, (bi::Location)0u>, bi::ParticleFilterBuffer<bi::BootstrapPFCache<(bi::Location)0u> > >; IO1 = bi::MCMCBuffer<bi::MCMCCache<(bi::Location)0u, bi::MCMCNetCDFBuffer> >; IO2 = bi::InputNetCDFBuffer; B = ModelSIR; F = bi::Filter<bi::BootstrapPF<ModelSIR, bi::Forcer<bi::InputNullBuffer, (bi::Location)0u>, bi::Observer<bi::InputNetCDFBuffer, (bi::Location)0u>, bi::Resampler > >; bi::ScheduleIterator = __gnu_cxx:: normal_iterator<const bi::ScheduleElement, std::vector >]’
src/sample_cpu.cpp:713:77: required from here
/usr/local/cuda/include/thrust/system/detail/generic/extrema.inl:221:89: error: ‘lowest’ is not a member of ‘std::numeric_limits’
initial = thrust::tuple<InputType, IndexType>(std::numeric_limits::lowest(), -1);
^
/usr/local/cuda/include/thrust/system/detail/generic/extrema.inl: In instantiation of ‘ForwardIterator thrust::system::detail::generic::max_element(thrust::execution_policy&, ForwardIterator, ForwardIterator, BinaryPredicate) [with DerivedPolicy = thrust::system::omp::detail::tag; ForwardIterator = thrust::permutation_iterator<const double , thrust::transform_iterator<bi::strided_functor, thrust::counting_iterator<long int, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default> >; BinaryPredicate = bi::nan_less_functor]’:
/usr/local/cuda/include/thrust/system/omp/detail/extrema.h:39:54: required from ‘ForwardIterator thrust::system::omp::detail::max_element(thrust::system::omp::detail::execution_policy&, ForwardIterator, ForwardIterator, BinaryPredicate) [with DerivedPolicy = thrust::system::omp::detail::tag; ForwardIterator = thrust::permutation_iterator<const double, thrust::transform_iterator<bi::strided_functor, thrust::counting_iterator<long int, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default> >; BinaryPredicate = bi::nan_less_functor]’
/usr/local/cuda/include/thrust/detail/extrema.inl:65:21: required from ‘ForwardIterator thrust::max_element(const thrust::detail::execution_policy_base&, ForwardIterator, ForwardIterator, BinaryPredicate) [with DerivedPolicy = thrust::system::omp::detail::tag; ForwardIterator = thrust::permutation_iterator<const double , thrust::transform_iterator<bi::strided_functor, thrust::counting_iterator<long int, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default> >; BinaryPredicate = bi::nan_less_functor]’
/usr/local/cuda/include/thrust/detail/extrema.inl:139:29: required from ‘ForwardIterator thrust::max_element(ForwardIterator, ForwardIterator, BinaryPredicate) [with ForwardIterator = thrust::permutation_iterator<const double, thrust::transform_iterator<bi::strided_functor, thrust::counting_iterator<long int, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::use_default, thrust::use_default> >; BinaryPredicate = bi::nan_less_functor]’
src/bi/state/../primitive/vector_primitive.hpp:870:32: required from ‘typename V1::value_type bi::max_reduce(V1) [with V1 = bi::host_vector_reference; typename V1::value_type = double]’
src/bi/state/../primitive/vector_primitive.hpp:936:21: required from ‘typename V1::value_type bi::logsumexp_reduce(V1) [with V1 = bi::host_vector_reference; typename V1::value_type = double]’
src/bi/filter/BootstrapPF.hpp:193:37: required from ‘void bi::BootstrapPF<B, F, O, R>::term(S1&) [with S1 = bi::BootstrapPFState<ModelSIR, (bi::Location)0u>; B = ModelSIR; F = bi::Forcer<bi::InputNullBuffer, (bi::Location)0u>; O = bi::Observer<bi::InputNetCDFBuffer, (bi::Location)0u>; R = bi::Resampler]’
src/bi/filter/Filter.hpp:68:3: required from ‘void bi::Filter::filter(bi::Random&, bi::ScheduleIterator, bi::ScheduleIterator, S1&, IO1&) [with S1 = bi::BootstrapPFState<ModelSIR, (bi::Location)0u>; IO1 = bi::ParticleFilterBuffer<bi::BootstrapPFCache<(bi::Location)0u> >; F = bi::BootstrapPF<ModelSIR, bi::Forcer<bi::InputNullBuffer, (bi::Location)0u>, bi::Observer<bi::InputNetCDFBuffer, (bi::Location)0u>, bi::Resampler >; bi::ScheduleIterator = __gnu_cxx::__normal_iterator<const bi::ScheduleElement , std::vector >]’
src/bi/sampler/MarginalMH.hpp:222:3: required from ‘void bi::MarginalMH<B, F>::init(bi::Random&, bi::ScheduleIterator, bi::ScheduleIterator, S1&, IO1&, IO2&) [with S1 = bi::BootstrapPFState<ModelSIR, (bi::Location)0u>; IO1 = bi::ParticleFilterBuffer<bi::BootstrapPFCache<(bi::Location)0u> >; IO2 = bi::InputNetCDFBuffer; B = ModelSIR; F = bi::Filter<bi::BootstrapPF<ModelSIR, bi::Forcer<bi::InputNullBuffer, (bi::Location)0u>, bi::Observer<bi::InputNetCDFBuffer, (bi::Location)0u>, bi::Resampler > >; bi::ScheduleIterator = gnu_cxx::__normal_iterator<const bi::ScheduleElement*, std::vector >]’
src/bi/sampler/MarginalMH.hpp:204:7: required from ‘void bi::MarginalMH<B, F>::sample(bi::Random&, bi::ScheduleIterator, bi::ScheduleIterator, S1&, int, IO1&, IO2&) [with S1 = bi::MarginalMHState<ModelSIR, (bi::Location)0u, bi::BootstrapPFState<ModelSIR, (bi::Location)0u>, bi::ParticleFilterBuffer<bi::BootstrapPFCache<(bi::Location)0u> > >; IO1 = bi::MCMCBuffer<bi::MCMCCache<(bi::Location)0u, bi::MCMCNetCDFBuffer> >; IO2 = bi::InputNetCDFBuffer; B = ModelSIR; F = bi::Filter<bi::BootstrapPF<ModelSIR, bi::Forcer<bi::InputNullBuffer, (bi::Location)0u>, bi::Observer<bi::InputNetCDFBuffer, (bi::Location)0u>, bi::Resampler > >; bi::ScheduleIterator = gnu_cxx::normal_iterator<const bi::ScheduleElement*, std::vector >]’
src/sample_cpu.cpp:713:77: required from here
/usr/local/cuda/include/thrust/system/detail/generic/extrema.inl:221:89: error: ‘lowest’ is not a member of ‘std::numeric_limits’
Makefile:1016: recipe for target 'src/sample_cpu.o' failed
make: *** [src/sample_cpu.o] Error 1
Error: make failed with return code 2, see /tmp/RtmpkB8HgN/SIR6c53e406f0f75/.SIR/build_assert_openmp_sm_30/make.log for details
at /usr/local/share/perl/5.22.1/Bi/FrontEnd.pm line 322.
Bi::FrontEnd::_error(Bi::FrontEnd=HASH(0x1c30f30), "make failed with return code 2, see /tmp/RtmpkB8HgN/SIR6c53e4"...) called at /usr/local/share/perl/5.22.1/Bi/FrontEnd.pm line 110
Bi::FrontEnd:: ANON("make failed with return code 2, see /tmp/RtmpkB8HgN/SIR6c53e4"...) called at /usr/local/share/perl/5.22.1/Bi/Builder.pm line 468
Bi::Builder::_make(Bi::Builder=HASH(0x1e46b90), "sample") called at /usr/local/share/perl/5.22.1/Bi/Builder.pm line 278
Bi::Builder::build(Bi::Builder=HASH(0x1e46b90), "sample") called at /usr/local/share/perl/5.22.1/Bi/FrontEnd.pm line 245
Bi::FrontEnd::client(Bi::FrontEnd=HASH(0x1c30f30)) called at /usr/local/share/perl/5.22.1/Bi/FrontEnd.pm line 135
eval {...} called at /usr/local/share/perl/5.22.1/Bi/FrontEnd.pm line 127
Bi::FrontEnd::do(Bi::FrontEnd=HASH(0x1c30f30)) called at /usr/local/bin/libbi line 36
at /usr/local/share/perl/5.22.1/Bi/FrontEnd.pm line 322.
Bi::FrontEnd::_error(Bi::FrontEnd=HASH(0x1c30f30), "Error: make failed with return code 2, see /tmp/RtmpkB8HgN/SI"...) called at /usr/local/share/perl/5.22.1/Bi/FrontEnd.pm line 110
Bi::FrontEnd::ANON__("Error: make failed with return code 2, see /tmp/RtmpkB8HgN/SI"...) called at /usr/local/share/perl/5.22.1/Bi/FrontEnd.pm line 138
Bi::FrontEnd::do(Bi::FrontEnd=HASH(0x1c30f30)) called at /usr/local/bin/libbi line 36
echo src/sample_cpu.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'
;\ g++ -DPACKAGE_NAME=\"LibBi\" -DPACKAGE_TARNAME=\"libbi\" -DPACKAGE_VERSION=\"1.4.4\" -DPACKAGE_STRING=\"LibBi\ 1.4.4\" -DPACKAGE_BUGREPORT=\"bug-report@libbi.org\" -DPACKAGE_URL=\"http://www.libbi.org\" -DHAVE_OMP_H=1 -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CPP -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_OMP -DHAVE_LIBM=1 -DHAVE_LIBGFORTRAN=1 -DHAVE_LIBATLAS=1 -DHAVE_LIBQRUPDATE=1 -DHAVE_LIBGSL=1 -DHAVE_LIBNETCDF=1 -DHAVE_NETCDF_H=1 -DHAVE_CBLAS_H=1 -DHAVE_GSL_GSL_CBLAS_H=1 -DHAVE_BOOST_MPL_IF_HPP=1 -DHAVE_BOOST_RANDOM_BINOMIAL_DISTRIBUTION_HPP=1 -DHAVE_BOOST_RANDOM_BERNOULLI_DISTRIBUTION_HPP=1 -DHAVE_BOOST_RANDOM_GAMMA_DISTRIBUTION_HPP=1 -DHAVE_BOOST_RANDOM_MERSENNE_TWISTER_HPP=1 -DHAVE_BOOST_RANDOM_NORMAL_DISTRIBUTION_HPP=1 -DHAVE_BOOST_RANDOM_POISSON_DISTRIBUTION_HPP=1 -DHAVE_BOOST_RANDOM_UNIFORM_INT_HPP=1 -DHAVE_BOOST_RANDOM_UNIFORM_REAL_HPP=1 -DHAVE_BOOST_RANDOM_VARIATE_GENERATOR_HPP=1 -DHAVE_BOOST_TYPEOF_TYPEOF_HPP=1 -DHAVE_THRUST_ADJACENT_DIFFERENCE_H=1 -DHAVE_THRUST_BINARY_SEARCH_H=1 -DHAVE_THRUST_COPY_H=1 -DHAVE_THRUST_DEVICE_PTR_H=1 -DHAVE_THRUST_DISTANCE_H=1 -DHAVE_THRUST_EXTREMA_H=1 -DHAVE_THRUST_FILL_H=1 -DHAVE_THRUST_FOR_EACH_H=1 -DHAVE_THRUST_FUNCTIONAL_H=1 -DHAVE_THRUST_GATHER_H=1 -DHAVE_THRUST_INNER_PRODUCT_H=1 -DHAVE_THRUST_ITERATOR_COUNTING_ITERATOR_H=1 -DHAVE_THRUST_ITERATOR_DETAIL_NORMAL_ITERATOR_H=1 -DHAVE_THRUST_ITERATOR_DISCARD_ITERATOR_H=1 -DHAVE_THRUST_ITERATOR_PERMUTATION_ITERATOR_H=1 -DHAVE_THRUST_ITERATOR_TRANSFORM_ITERATOR_H=1 -DHAVE_THRUST_ITERATOR_ZIP_ITERATOR_H=1 -DHAVE_THRUST_LOGICAL_H=1 -DHAVE_THRUST_REDUCE_H=1 -DHAVE_THRUST_SCAN_H=1 -DHAVE_THRUST_SEQUENCE_H=1 -DHAVE_THRUST_SORT_H=1 -DHAVE_THRUST_TRANSFORM_H=1 -DHAVE_THRUST_TRANSFORM_REDUCE_H=1 -DHAVE_THRUST_TRANSFORM_SCAN_H=1 -DHAVE_THRUST_TUPLE_H=1 -DHAVE_GSL_GSL_MULTIMIN_H=1 -DENABLE_DIAGNOSTICS=no -DHAVE_STDBOOL_H=1 -I. -Isrc -I/usr/local/cuda/include -DCUDA_FAST_MATH=0 -DENABLE_OPENMP -fopenmp -O3 -g3 -funroll-loops -MT src/sample_cpu.o -MD -MP -MF $depbase.Tpo -c -o src/sample_cpu.o src/sample_cpu.cpp &&\ mv -f $depbase.Tpo $depbase.Po In file included from /usr/local/cuda/include/thrust/system/detail/generic/extrema.h:88:0, from /usr/local/cuda/include/thrust/detail/extrema.inl:22, from /usr/local/cuda/include/thrust/extrema.h:802, from src/bi/state/../primitive/vector_primitive.hpp:787, from src/bi/state/../primitive/matrix_primitive.hpp:11, from src/bi/state/State.hpp:467, from src/model/ModelSIR.hpp:31, from src/sample_cpu.cpp:19: /usr/local/cuda/include/thrust/system/detail/generic/extrema.inl: In instantiation of ‘ForwardIterator thrust::system::detail::generic::max_element(thrust::execution_policy