Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rstan or cmdstanr packages don't work #52

Open
lsaravia opened this issue Dec 24, 2022 · 3 comments
Open

rstan or cmdstanr packages don't work #52

lsaravia opened this issue Dec 24, 2022 · 3 comments

Comments

@lsaravia
Copy link

lsaravia commented Dec 24, 2022

I used the template to create a binder repository

https://github.com/lsaravia/binder-rethinking

in the Install.R file

install.packages(c("StanHeaders","rstan"),type="source")

or

install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

in both cases the package seems to be well installed but when I test the installation using:

example(stan_model, package = "rstan", run.dontrun = TRUE)
Loading required package: StanHeaders

rstan version 2.26.13 (Stan version 2.26.1)

For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
For within-chain threading using `reduce_sum()` or `map_rect()` Stan functions,
change `threads_per_chain` option:
rstan_options(threads_per_chain = 1)
make cmd is
  make -f '/usr/local/lib/R/etc/Makeconf' -f '/usr/local/lib/R/share/make/shlib.mk' CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB='file273f221760.so' OBJECTS='file273f221760.o'

.
.  
.
make would use
g++ -std=gnu++14 -I"/usr/local/lib/R/include" -DNDEBUG   -I"/usr/local/lib/R/site-library/Rcpp/include/"  -I"/usr/local/lib/R/site-library/RcppEigen/include/"  -I"/usr/local/lib/R/site-library/RcppEigen/include/unsupported"  -I"/usr/local/lib/R/site-library/BH/include" -I"/usr/local/lib/R/site-library/StanHeaders/include/src/"  -I"/usr/local/lib/R/site-library/StanHeaders/include/"  -I"/usr/local/lib/R/site-library/RcppParallel/include/"  -I"/usr/local/lib/R/site-library/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  -DBOOST_NO_AUTO_PTR  -include '/usr/local/lib/R/site-library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c file273f221760.cpp -o file273f221760.o
if test  "zfile273f221760.o" != "z"; then \
  echo g++ -std=gnu++14 -shared -L"/usr/local/lib/R/lib" -L/usr/local/lib -o file273f221760.so file273f221760.o  '/usr/local/lib/R/site-library/rstan/lib//libStanServices.a' -L'/usr/local/lib/R/site-library/StanHeaders/lib/' -lStanHeaders -L'/usr/local/lib/R/site-library/RcppParallel/lib/' -ltbb   -L"/usr/local/lib/R/lib" -lR; \
  g++ -std=gnu++14 -shared -L"/usr/local/lib/R/lib" -L/usr/local/lib -o file273f221760.so file273f221760.o  '/usr/local/lib/R/site-library/rstan/lib//libStanServices.a' -L'/usr/local/lib/R/site-library/StanHeaders/lib/' -lStanHeaders -L'/usr/local/lib/R/site-library/RcppParallel/lib/' -ltbb   -L"/usr/local/lib/R/lib" -lR; \
fi

Here binder virtual machine hangs

A similar thing happens when I also install cmdstanr I think that could be the same problem.

@eddelbuettel
Copy link
Member

Shooting from the hip: the combination of 'C++ involved' and 'hangs or crashes' in conjunction with a VM or container is most often related to a lack of memory. Can you try the same installation commands, and test example, in a normal machine? It may just be that the (free, if I am not mistaken) binder resources are limited in scope.

@lsaravia
Copy link
Author

So the solution would be to create a docker image with rstan and cmdstanr already compiled.

@eddelbuettel
Copy link
Member

Yes relying on binaries removes the constraint of small system while building.

It does not remove the constraint of a small system when running. Binder sessions, free as they are, may not be suitable for all stan applications if and when those involve C++ compilations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants