Error running Stan on AWS

it looks like a similar symptom (& some suggested fixes to try) was mentioned a few months ago in this thread: Problem compiling STAN program (via brms) on HPC

If that doesn’t work, here’s one strategy to go about debugging it:

  • distill the failing program down to a minimal example (your code looks pretty minimal)
  • confirm you can get the minimal example to run locally in your own development environment, without the extra layers of complexity from running it inside AWS EC2
  • or alternatively, if you can get the minimal example to fail in the same way locally in your own development environment, maybe that hints there’s a flaw in the script
  • try to figure out what the differences are (if any) between your local dev environment and the remote AWS dev environment inside the AMI virtual machine image you are running (operating system type & version, R version, Stan version, C++ compiler version, CPU architecture (amd64? arm64?).

Another debugging tactic is “try to run it locally with the exact configuration you are trying to use remotely, and see if you can reproduce the exact fault”. It looks like you are running RStudio inside amazon EC2 service using amazon’s proprietary AMI virtual machine image format. I don’t think there is a way to run an AMI virtual machine locally, but apparently it is possible to export some AMI images to vmware virtual machine images which you may then be able to run locally using vmware player software. This probably isn’t a useful direction to explore, as the issue is almost certainly related to the configuration of software inside the virtual machine image, not anything to do with amazon’s EC2 platform.