Within-chain parallelisation on M1 Mac for CmdStanr

Hi, I am wondering if Stan currently (or will in future) supports within-chain parallelisation for arm64 Macs? I am trying to run an example model (from dschrage / rcovreg · GitLab) and constantly get thrown this error:

dyld[25746]: Library not loaded: @rpath/libtbb.dylib
Reason: tried: ‘~/.cmdstanr/cmdstan-2.28.2/stan/lib/stan_math/lib/tbb/libtbb.dylib’ (mach-o file, but is an incompatible architecture (have ‘arm64’, need ‘x86_64’)),

The error goes away after removing “cpp_options = list(stan_threads = TRUE)” from the model.

R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.2

This part seems to suggest that this is installation is a bit weird. As it is looking for x86, which is the non-Mac version.

Within-chain parallelization should work on M1 Mac with CmdStanR, there are quite a few reports of it working pretty well actually.

Thanks! Any idea how to resolve this? I’ve rebuilt CmdStan and reinstalled but to no avail. Seems like the issue is with the tbb library.

Update: Apologies, managed to run within-chain parallelisation with the brms example (Running brms models with within-chain parallelization). Issue could have been with the way the example from before was coded.

1 Like