CmdstanR running on Shiny + Docker crashes

I have a Shiny app that reads some csv files and runs Stan (CmdstanR), fitting a model with 2 chains. When I run the Shiny App locally on my Laptop in runs with no issues. However if I build a docker image and run on port 3838 the process runs up until this point:

Running MCMC with 2 parallel chains, with 1 thread(s) per chain…

But then crashes.

Warning: Chain 1 finished unexpectedly!
Warning: Chain 2 finished unexpectedly!
Warning: All chains finished unexpectedly! Use the $output(chain_id) method for more information.
Warning: Use read_cmdstan_csv() to read the results of the failed chains.
Warning: No chains finished successfully. Unable to retrieve the fit.

I’m running this on an M1 Mac (Big Sur) maybe not relevant as the model runs with no issues on the Shiny App locally, yet crashes when “dockerized” via:

docker run -it -p 3838:3838 stan_shiny_app

Thanks for the help.

Extra info:
This is cmdstanr version

  • Online documentation and vignettes at R Interface to CmdStan • cmdstanr
  • CmdStan path set to: /root/.cmdstan/cmdstan-2.27.0
  • Use set_cmdstan_path() to change the path
    This is posterior version 0.1.7
1 Like

not sure what is happening, we would need a lot more info. But it seems Stan is not properly installed within the docker image (which is likely quite separate from whehter Stan is properly installed on your machine). Can you try running a normal R session within the docker image and see if you can run cmdstanr examples from there?