I’m running a variational bayes model in rstan in a docker container on AWS Fargate. A similar container runs fine on AWS Lambda, but when I switch to the Fargate EC2 instance, the VB crashes and I get the following error:
"
Chain 1: 1200 -31633.462 0.120 0.016
Chain 1: 1300 -31591.262 0.111 0.010
Chain 1: 1400 -31566.196 0.103 0.010
Chain 1: 1500 -31543.113 0.096 0.007 MEDIAN ELBO CONVERGED
Chain 1:
Chain 1: Drawing a sample of size 5000 from the approximate posterior...
double free or corruption (out)
Aborted (core dumped)"
where my stan model is invoked using:
posterior_irt <- rstan::vb(object = stan_model, data = full_data, iter = 30000, output_samples = 5000, init = 0)
The instance runs a docker container that I base off of rocker/r-ubuntu:20.04
during the docker build, I run an R script which I borrowed off the web:
Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)
Sys.setenv(MAKEFLAGS = paste0(“-j”,parallel::detectCores()))
install.packages(c(“StanHeaders”,“rstan”),type=“source”)
Creating /home/rstudio/.R/Makevars
dotR ← file.path(Sys.getenv(“HOME”), “.R”)
if (!file.exists(dotR)) dir.create(dotR)
M ← file.path(dotR, “Makevars”)
if (!file.exists(M)) file.create(M)
cat(“\nCXX14FLAGS=-O3 -march=native -mtune=native -fPIC”,
“CXX14=g++”,
file = M, sep = “\n”, append = TRUE)
I should also add that I’m actually running the r script using rpy2 from python as I need to use the AWS boto3 API for other features of the program. The instance is ephemeral, and as such, I’m not sure how to retrieve the makevars file.
Any help would be massively appreciated.
Jesse