Running cmdstan on ventura

I just updated my mac OS to Ventura, and I’m having issues running cmdstan. I updated XTools and reinstalled cmdstan from GitHub. But I’m not able to build the library. Here is the error message.

MacBook-Pro-257:cmdstan charlesm$ make build
curl -L https://github.com/stan-dev/stanc3/releases/download/nightly/mac-stanc -o bin/stanc --retry 5 --retry-delay 10
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 10.8M  100 10.8M    0     0  4923k      0  0:00:02  0:00:02 --:--:-- 9410k
chmod +x bin/stanc

--- Compiling the main object file. This might take up to a minute. ---
clang++    -c -o src/cmdstan/main.o src/cmdstan/main.cpp
src/cmdstan/main.cpp:1:10: fatal error: 'cmdstan/command.hpp' file not found
#include <cmdstan/command.hpp>
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [src/cmdstan/main.o] Error 1

And I get the same error message when I try to transpile the original Bernoulli example.

The missing file does exist under source/cmsdtan/command.hpp, so I’m not sure what’s causing the error.

I’m using Xcode version 14.3 and xcode-select version 2397. Here are the versions of the compilers:

make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

MacBook-Pro-257:cmdstan charlesm$ clang++ --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

MacBook-Pro-257:cmdstan charlesm$ g++ --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Any guidance as to what might be going wrong is greatly appreciated.

@jonah @rok_cesnovar

Quick question, was this upgrade or clean install?

It looks like there’s a problem with your Makefiles. The compilation call is missing all of the stan flags/includes:

That is, this line:

--- Compiling the main object file. This might take up to a minute. ---
clang++    -c -o src/cmdstan/main.o src/cmdstan/main.cpp

Should look like this:

--- Compiling the main object file. This might take up to a minute. ---
clang++ -Wno-deprecated-declarations -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -o src/cmdstan/main.o src/cmdstan/main.cpp

If you use one of the releases, rather than the github version, do you get the same behaviour?

I agree with @andrjohns. I think this might be a case of cloning just cmdstan and not cloning recursively.

Hi all,

Upgrade for the Mac OS, clean install for cmdstan.

I downloaded the released version. Running make build works (although it generates a lot of warning messages). On the other hand, make examples/bernoulli/bernoulli returns an error.

MacBook-Pro-257:cmdstan-2.31.0 charlesm$ make examples/bernoulli/bernoulli
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -MT stan/src/stan/model/model_header.hpp.gch -MT stan/src/stan/model/model_header.d -MM -E -MG -MP -MF stan/src/stan/model/model_header.d stan/src/stan/model/model_header.hpp
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -MT src/cmdstan/main.o -MM -E -MG -MP -MF src/cmdstan/main.d src/cmdstan/main.cpp

--- Translating Stan model to C++ code ---
bin/stanc  --o=examples/bernoulli/bernoulli.hpp examples/bernoulli/bernoulli.stan

--- Compiling, linking C++ code ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -include-pch stan/src/stan/model/model_header.hpp.gch -x c++ -o examples/bernoulli/bernoulli.o examples/bernoulli/bernoulli.hpp
examples/bernoulli/bernoulli.hpp:15:7: warning: abstract class is marked 'final' [-Wabstract-final-class]
class bernoulli_model final : public model_base_crtp<bernoulli_model> {
      ^
/Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/src/stan/model/model_base.hpp:75:16: note: unimplemented pure virtual method 'get_param_names' in 'bernoulli_model'
  virtual void get_param_names(std::vector<std::string>& names) const = 0;
               ^
/Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/src/stan/model/model_base.hpp:94:16: note: unimplemented pure virtual method 'get_dims' in 'bernoulli_model'
  virtual void get_dims(std::vector<std::vector<size_t> >& dimss) const = 0;
               ^
examples/bernoulli/bernoulli.hpp:302:23: error: allocating an object of abstract class type 'stan_model' (aka 'bernoulli_model_namespace::bernoulli_model')
  stan_model* m = new stan_model(data_context, seed, msg_stream);
                      ^
In file included from examples/bernoulli/bernoulli.hpp:1:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/src/stan/model/model_header.hpp:4:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/stan/math.hpp:19:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/stan/math/rev.hpp:10:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/stan/math/rev/fun.hpp:198:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/stan/math/prim/functor.hpp:14:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/stan/math/prim/functor/integrate_ode_rk45.hpp:6:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/stan/math/prim/functor/ode_rk45.hpp:9:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/lib/boost_1.78.0/boost/numeric/odeint.hpp:76:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/lib/boost_1.78.0/boost/numeric/odeint/integrate/observer_collection.hpp:23:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/lib/boost_1.78.0/boost/function.hpp:30:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/lib/boost_1.78.0/boost/function/detail/prologue.hpp:17:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/lib/boost_1.78.0/boost/function/function_base.hpp:21:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/lib/boost_1.78.0/boost/type_index.hpp:29:
In file included from /Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/lib/boost_1.78.0/boost/type_index/stl_type_index.hpp:47:
/Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/lib/boost_1.78.0/boost/container_hash/hash.hpp:132:33: warning: 'unary_function<const std::error_category *, unsigned long>' is deprecated [-Wdeprecated-declarations]
        struct hash_base : std::unary_function<T, std::size_t> {};
                                ^
/Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/lib/boost_1.78.0/boost/container_hash/hash.hpp:692:18: note: in instantiation of template class 'boost::hash_detail::hash_base<const std::error_category *>' requested here
        : public boost::hash_detail::hash_base<T*>
                 ^
/Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/lib/boost_1.78.0/boost/container_hash/hash.hpp:420:24: note: in instantiation of template class 'boost::hash<const std::error_category *>' requested here
        boost::hash<T> hasher;
                       ^
/Users/charlesm/Desktop/Teaching/cmdstan-2.31.0/stan/lib/stan_math/lib/boost_1.78.0/boost/container_hash/hash.hpp:551:9: note: in instantiation of function template specialization 'boost::hash_combine<const std::error_category *>' requested here
        hash_combine(seed, &v.category());
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/unary_function.h:23:29: note: 'unary_function<const std::error_category *, unsigned long>' has been explicitly marked deprecated here
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 unary_function
                            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:825:41: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX11'
#    define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
                                        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:810:49: note: expanded from macro '_LIBCPP_DEPRECATED'
#      define _LIBCPP_DEPRECATED __attribute__((deprecated))
                                                ^
2 warnings and 1 error generated.
make: *** [examples/bernoulli/bernoulli] Error 1

If it helps, I can post the output of make build (very long).

Are you using a nightly/custom build of stanc here? Those errors happen when using 2.31 Stan headers with a more recent stanc version

An easy way to check, for the “release” version you should see:

> bin/stanc --version          
stanc3 v2.31.0 (Unix)

And for a nightly version:

> bin/stanc --version         
stanc3 v2.31.0-116-gcafcd694 (Unix)

Ah, it looks like I was using a nightly version. I downloaded cmdstan-2.31.0-linux-arm64.tar.gz (since it was the tar at the top) got the nightly version. Downloading cmdstan-2.31.0.tar.gz gives me the released version. I’m able to build Stan and transpile Bernoulli. (still with warning messages).

think this might be a case of cloning just cmdstan and not cloning recursively.

@rok_cesnovar what would I need to do to clone recursively, and moreover why does installing via git clone not work? (@yizhang this could be an issue for installing Torsten).

When you run :

git clone https://github.com/stan-dev/cmdstan

It only clones the cmdstan files & headers, not the Stan and Math files - because those are git submodules that need to be initialised first. This can be done automatically by adding the --recursive flag, which will initialise and clone all submodules:

git clone --recursive https://github.com/stan-dev/cmdstan

EDIT: This is also covered in the repo README: GitHub - stan-dev/cmdstan: CmdStan, the command line interface to Stan

Note also that the arch-specific release (e.g., -arm64, -s90x, etc.) are targeted for linux distributions.

Mac users can download the ‘normal’ release (i.e., no arch suffix), since the mac stanc is compiled for x86_64, but run through rosetta on Apple Silicon.

I ran into the above problem as well, I am running on M2 and figured I’d better just compile from source.

Works fine once the recursive git clone is done.

However, I am getting a ton of deprecation warnings from boost, setup is:

Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

% make --version
GNU Make 3.81

I assume we are stuck with this due to boost not being sorted out.

However testing the install generates a bunch of text with a warning again from boost:

cmdstan % make examples/bernoulli/bernoulli

--- Translating Stan model to C++ code ---
bin/stanc  --o=examples/bernoulli/bernoulli.hpp examples/bernoulli/bernoulli.stan

--- Compiling, linking C++ code ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.4.0 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -include-pch stan/src/stan/model/model_header.hpp.gch -x c++ -o examples/bernoulli/bernoulli.o examples/bernoulli/bernoulli.hpp
In file included from examples/bernoulli/bernoulli.hpp:1:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/src/stan/model/model_header.hpp:4:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/stan/math.hpp:19:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/stan/math/rev.hpp:10:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/stan/math/rev/fun.hpp:198:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/stan/math/prim/functor.hpp:15:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/stan/math/prim/functor/integrate_ode_rk45.hpp:6:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/stan/math/prim/functor/ode_rk45.hpp:9:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/boost_1.78.0/boost/numeric/odeint.hpp:76:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/boost_1.78.0/boost/numeric/odeint/integrate/observer_collection.hpp:23:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/boost_1.78.0/boost/function.hpp:30:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/boost_1.78.0/boost/function/detail/prologue.hpp:17:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/boost_1.78.0/boost/function/function_base.hpp:21:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/boost_1.78.0/boost/type_index.hpp:29:
In file included from /Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/boost_1.78.0/boost/type_index/stl_type_index.hpp:47:
/Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/boost_1.78.0/boost/container_hash/hash.hpp:132:33: warning: 'unary_function<const std::error_category *, unsigned long>' is deprecated [-Wdeprecated-declarations]
        struct hash_base : std::unary_function<T, std::size_t> {};
                                ^
/Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/boost_1.78.0/boost/container_hash/hash.hpp:692:18: note: in instantiation of template class 'boost::hash_detail::hash_base<const std::error_category *>' requested here
        : public boost::hash_detail::hash_base<T*>
                 ^
/Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/boost_1.78.0/boost/container_hash/hash.hpp:420:24: note: in instantiation of template class 'boost::hash<const std::error_category *>' requested here
        boost::hash<T> hasher;
                       ^
/Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/boost_1.78.0/boost/container_hash/hash.hpp:551:9: note: in instantiation of function template specialization 'boost::hash_combine<const std::error_category *>' requested here
        hash_combine(seed, &v.category());
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/unary_function.h:23:29: note: 'unary_function<const std::error_category *, unsigned long>' has been explicitly marked deprecated here
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 unary_function
                            ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:825:41: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX11'
#    define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
                                        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:810:49: note: expanded from macro '_LIBCPP_DEPRECATED'
#      define _LIBCPP_DEPRECATED __attribute__((deprecated))
                                                ^
1 warning generated.
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.4.0 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS               -Wl,-L,"/Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/tbb"        examples/bernoulli/bernoulli.o src/cmdstan/main.o       -Wl,-L,"/Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/fbaldw522/Downloads/cmdstan/stan/lib/stan_math/lib/tbb"     stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_kinsol.a  stan/lib/stan_math/lib/tbb/libtbb.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc_proxy.dylib -o examples/bernoulli/bernoulli
rm -f examples/bernoulli/bernoulli.o

I assume that nothing can be done about this since we don’t run boost but thought I’d check.

thanks

Breck

I assume that nothing can be done about this since we don’t run boost but thought I’d check.

Unfortunately so.

You can suppress this by adding CXXFLAGS += -Wno-deprecated-declarations to your make/local file, if that helps

There’s an open issue to update Boost to 1.81, I wonder if they have fixed those warnings upstream or not

Mac users can download the ‘normal’ release (i.e., no arch suffix), since the mac stanc is compiled for x86_64, but run through rosetta on Apple Silicon.

Are there any plans for an Apple silicon version? (I understand the actual models are native, which I know is more important. )

We haven’t yet seen the need for an Apple silicon-specific build of stanc. I believe it would be possible, since OCaml now supports native builds on that platform and we have a CI machine which is Apple silicon based, but at the moment it doesn’t seem like there’s a particular advantage.

Our current build pipeline for stanc builds a mac binary which can be used all the way back on MacOS 10.11 El Capitan

I can confirm git clone --recursive works (both for installing stan and Torsten). @yizhang , for the latter, we should update the documentation.

Thank you for all the help!

1 Like