I am coming to the conclusion that using Stan in binder, specifically using Stan via
rstan in an RStudio based binder project, is not going to work. The reason is a RAM issue, I am tentatively concluding.
After trying and failing with a few other approaches, I managed to get an RStudio binder with
brms installed. This required making my own Docker image, which I uploaded to DockerHub, as described here.
For reference, the relevant GitHub repo is here, and here’s the binder launch button:
If we try the little test script therein named
hello.R, whose contents are following
library(tidyverse) library(brms) data_df <- tibble(x = rnorm(10)) M <- brm(x ~ 1, data = data_df)
the compiling of the sampler fails after about 2 or 3 minutes of silence.
The error message is, in my experience, a typical somewhat uninformative message effectively saying the compiler did not compile, e.g.
Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! file504ae4af77.cpp:6:36: warning: ISO C++11 requires whitespace after the macro name #define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp> ... ... /usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:61:40: warning ￼ Show Traceback ￼ Rerun with Debug Error in sink(type = "output") : invalid connection
Given that this binder project is based on a custom Dockerfile (in repo), on my local machine, I can cd into my local clone of the repo and do
docker build -t hellobinder_with_rstan_test .
and then run it locally with
docker run -p 8888:8888 hellobinder_with_rstan_test:latest
and that launches and I can open RStudio and run my
hello.R and it all works.
The C++ compiler for Stan uses a lot of RAM, even for tiny models, such as in my example. I assume I hit some RAM threshold for my binder project and that interrupted the compiling. From this, I am tentatively concluding that getting binder to run even tiny Stan models is just not going to work because of the RAM demands.
Would that be a safe conclusion to draw?