Last active
June 18, 2024 11:40
-
-
Save lindemann09/5bead1ce0320974ac4f6 to your computer and use it in GitHub Desktop.
CmdStan installation script for Debian Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # Linux installation script for CmdStan (http://mc-stan.org/) | |
| # Downloads and installs CmdStan on DEBIAN/UBUNTU LINUX | |
| # The following shell commands will be created (/usr/bin/...): | |
| # stanc | |
| # stan_make | |
| # stan_print | |
| # | |
| # Please adapt VERSION number! | |
| # | |
| # (c) O. Lindemann, U Potsdam | |
| VERSION=2.6.2 | |
| # dependencies | |
| sudo apt-get install curl libxml2-dev | |
| # download | |
| cd /tmp | |
| wget https://github.com/stan-dev/cmdstan/releases/download/v${VERSION}/cmdstan-${VERSION}.tar.gz | |
| # extract | |
| tar xzf cmdstan-${VERSION}.tar.gz | |
| cd cmdstan-${VERSION} | |
| # make | |
| make build -j2 | |
| cd /tmp | |
| # move to cmdStan to /opt | |
| sudo rm -rf /opt/cmdstan-${VERSION} | |
| sudo mv cmdstan-${VERSION} /opt/ | |
| # STANC | |
| sudo ln -fs /opt/cmdstan-${VERSION}/bin/stanc /usr/bin | |
| # STAN_PRINT | |
| sudo ln -fs /opt/cmdstan-${VERSION}/bin/print /usr/bin/stan_print | |
| # STAN_MAKE | |
| STANMAKE=/opt/cmdstan-${VERSION}/bin/stan_make | |
| TMP=/tmp/stan_make.tmp.sh | |
| echo "#!/bin/bash" > ${TMP} | |
| echo "#" >> ${TMP} | |
| echo "# Bash script for compiling stan models" >> ${TMP} | |
| echo "# Usage: stan_make.sh <stan model file>" >> ${TMP} | |
| echo "#" >> ${TMP} | |
| echo "# (c) O. Lindemann" >> ${TMP} | |
| echo "" >> ${TMP} | |
| echo "STAN_FOLDER=/opt/cmdstan-${VERSION}/" >> ${TMP} | |
| echo "" >> ${TMP} | |
| echo "FILE=\$(realpath \${1})" >> ${TMP} | |
| echo "DIR=\${FILE%/*} " >> ${TMP} | |
| echo "FLNAME=\${FILE##*/}" >> ${TMP} | |
| echo "FLNAME_NO_SUFFIX=\${FLNAME%.*}" >> ${TMP} | |
| echo "# complile from stan folder" >> ${TMP} | |
| echo "cd \$STAN_FOLDER" >> ${TMP} | |
| echo "make \${DIR}/\${FLNAME_NO_SUFFIX}" >> ${TMP} | |
| chmod +x ${TMP} | |
| sudo mv ${TMP} ${STANMAKE} | |
| sudo ln -fs ${STANMAKE} /usr/bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sadly does not seem to compile nicely on Debian bullseye:
this search implies that
libstdc++-10-devshould provide it, but this does not avail me. I'll try to remember to update this comment if I figure it out.The
cstddeffile that triggers this lives in/usr/include/c++/10/, which does contain abitsfolder but not with that file. The file it wants is in/usr/include/i386-linux-gnu/c++/10/bits.this discussion looks relevant. It seems on Debian with this version of cmdstan we're using the wrong stdlib; libstdc++ has the includes I need but I am struggling to force Stan to use it, which the linked discussion suggests will work.
I have discovered I can affect this stage by editing
stan/lib/stan_math/lib/tbb_2020.3/build/Makefile.tbbmalloc, but this has not helped yet. I think-stdveris the flag I want to manipulate.I've tried to build tbb with
clanginstead ofg++withmake compiler=clangbut I get the same error, just from a different compiler. I can however change the behaviour by specifyingmake compiler=clang CXXFLAGS+=-stdlib=libc++upon which now#include <cstddef>fails.I've asked on the Stan discourse: https://discourse.mc-stan.org/t/unable-to-build-cmdstan-2-30-1-on-debian-bullseye-bits-c-config-h-tbbmalloc/29149
e: Solved, see above discourse link for solution.