-
-
Save lindemann09/5bead1ce0320974ac4f6 to your computer and use it in GitHub Desktop.
#!/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 |
Sadly does not seem to compile nicely on Debian bullseye:
make[1]: Entering directory '/tmp/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb'
g++ -c -MMD -O2 -g -DDO_ITT_NOTIFY -DUSE_PTHREAD -pthread -m64 -mrtm -Wno-unknown-warning-option -Wno-deprecated-copy -Wno-missing-attributes -Wno-class-memaccess -Wno-sized-deallocation -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1 -fno-rtti -fno-exceptions -D__TBBMALLOC_BUILD=1 -Wno-parentheses -Wno-sized-deallocation -fPIC -flifetime-dse=1 -I../tbb_2020.3/src -I../tbb_2020.3/src/rml/include -I../tbb_2020.3/include -I../tbb_2020.3/src/tbbmalloc -I../tbb_2020.3/src/tbbmalloc ../tbb_2020.3/src/tbbmalloc/backend.cpp
In file included from ../tbb_2020.3/include/tbb/tbb_config.h:36,
from ../tbb_2020.3/include/tbb/tbb_stddef.h:91,
from ../tbb_2020.3/src/tbbmalloc/Customize.h:21,
from ../tbb_2020.3/src/tbbmalloc/TypeDefinitions.h:54,
from ../tbb_2020.3/src/tbbmalloc/tbbmalloc_internal.h:21,
from ../tbb_2020.3/src/tbbmalloc/backend.cpp:19:
/usr/include/c++/10/cstddef:49:10: fatal error: bits/c++config.h: No such file or directory
49 | #include <bits/c++config.h>
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [/tmp/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb_2020.3/build/Makefile.tbbmalloc:65: backend.o] Error 1
make[1]: Leaving directory '/tmp/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb'
make: *** [stan/lib/stan_math/make/libraries:173: stan/lib/stan_math/lib/tbb/tbbmalloc.def] Error 2
make: *** Waiting for unfinished jobs....
this search implies that libstdc++-10-dev
should provide it, but this does not avail me. I'll try to remember to update this comment if I figure it out.
The cstddef
file that triggers this lives in /usr/include/c++/10/
, which does contain a bits
folder 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 -stdver
is the flag I want to manipulate.
I've tried to build tbb with clang
instead of g++
with make compiler=clang
but I get the same error, just from a different compiler. I can however change the behaviour by specifying make 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.
Install CmdStan