Compiling CmdStan from source in an Apptainer container - “Exec format error"

I am trying to install CmdStan (2.36.0) in an Apptainer container based on the Docker image rocker/r-base:4.4.1. I download the .tar.gz from source using wget and then use make to build it:

export CMDSTAN=“/opt/cmdstan”
mkdir -p ${CMDSTAN}
cd /opt/ &&
  wget https://github.com/stan-dev/cmdstan/releases/download/v2.36.0/cmdstan-2.36.0-linux-arm64.tar.gz
tar -xvf \
      cmdstan-2.36.0-linux-arm64.tar.gz \
      --no-same-owner --no-same-permissions
mv /opt/cmdstan-2.36.0/* ${CMDSTAN}
cd ${CMDSTAN}
make build

After a while, I finally get:

--- CmdStan v2.36.0 built —

However, when I run

make examples/bernoulli/bernoulli

I get the following error:

--- Translating Stan model to C++ code ---
bin/stanc  --o=examples/bernoulli/bernoulli.hpp examples/bernoulli/bernoulli.stan
bash: line 1: bin/stanc: cannot execute binary file: Exec format error
make: *** [make/program:66: examples/bernoulli/bernoulli.hpp] Error 126

Any hints on what is going on and (hopefully) how to fix it?

  • Operating System: Debian GNU/Linux trixie/sid
  • CmdStan Version: 2.36.0
  • Compiler/Toolkit: GCC 13.2.0

Can you share a bit about the CPU you are using? You’re downloading a tarball specific to ARM processors

1 Like

I did not realize I was downloading the tar for the arm architecture (even though it is clear from the filename). The architecture of the CPU I’m working with is x86_64.

I downloaded the tar file that does not specify the architecture instead and everything worked as expected. Thank you for pointing the problem with the architecture out.

1 Like