Will the new M1 chip affect cmdstanR?

Hi all,

I used to be a Windows user but recently I found that using MacBook Pro might make my life easier in using Python (Pystan) and command line based computing (cluster computing, cmdstanR). However I heard some bad news on the effect of new M1 chip on some software. Just curious will this affect my user experience or I should still choose the older version with Intel chip?


1 Like


we do not expect issues there, but until we test on a real machine we wont really know. Cmdstanr and also rstan runs without a problem on Linux + ARM, which will hopefully transfer to macs.

You will definitely have to install all R packages from source for some time as CRAN will not build them until they get a M1 machine. This does not affect cmdstanr but might affect your overall R experience.


Some more info on this:

R & RStudio will run using the Rosseta 2 dynamic translation from Intel binary to ARM binary for some time. At least until there is a Fortran 90 compiler for the M1 chip. R requires that to build native binaries for M1. Until that happens I expect R/Rstudio to run considerably slower compared to Intel machines.

More info here:


The other thing is that M1 will not allow the use of more than 16GB of RAM. But that is not an issue many will hit.

Actually… looks like it might be faster even under Rosetta2: https://twitter.com/kjhealy/status/1328718684492279808?s=20

Actually with 8 cores it will be quite easy to fill 16 GB of RAM if doing parallel calculations. I’ve maxed out 64GB RAM on several occasions this way in R. Maybe folks don’t run Stan models that big though.


Nice! Though we can’t really say how much of that is due to the lightning fast SSDs in the new Mac’s. I do expect native M1 code to be faster than Intel in the end.

Based on the tweet we also have a timeframe for the native R for M1: April 2021.
Thanks for the link!


A quick update:

A user reported that cmdstan via cmdstanr works OK after adding
CXX="arch -arch arm64e clang++" to the makefile flags.

So for cmdstan you need to add the following to to make/local and rebuild cmdstan
CXX="arch -arch arm64e clang++"

For cmdstanr you need to run

cmdstanr::cmdstan_make_local(cpp_options = list(CXX="arch -arch arm64e clang++"))

and then everything should work fine. The next cmdstan version will handle this automatically.


Nice! Any word from them on speed of Stan on M1 ?

I wondered just that. Posted the question on the PR: https://github.com/stan-dev/math/pull/2208

Hi All,

These are all benchmarks of a model I’m working on:

mid-2013 1.3Ghz Intel MacBook Air: ~490 seconds
M1 MacBook Pro under Rosetta 2: ~240 seconds
M1 MacBook Pro native Arm: ~125 seconds.

It seems like going native arm64 is worth the hassle!

Kind wishes,


This is what I did to make it work:

In the Terminal.app, not the terminal window in RStudio

cd ~
git clone --recursive https://github.com/stan-dev/cmdstan.git
cd cmdstan/stan/lib/stan_math
git remote add nicokist git@github.com:nicokist/math.git
git pull nicokist bigsur_arm64
git checkout bigsur_arm64
cd ../../..
make build

in R:

cmdstanr::cmdstan_make_local(cpp_options = list(CXX="arch -arch arm64e clang++"))
cmdstanr_example(example = 'schools_ncp')

Just to clarify, in order to build cmdstan this also requires the makefile fix?

I don’t think so, since I built it from the Mac OS Terminal it’s automatically an arm64 executable. I’ve updated my previous post to make that clearer.

I think for the building stan/stan-math/cmdstan from the Rosetta 2 R environment it’s probably better to use arch -arch arm64e make build rather than adjust CXX, as boost gave an error when I tried adjusting CXX and running rebuild_cmdstan(), I guess because it uses more than just the c++ compiler…


I can confirm that the current CmdStan head (a1da476309edae7bbed19866f9ddbc1e16df995c for me) builds correctly out of the box on my M1 Mac. There are a lot of deprecation warnings and some linker warnings, but it doesn’t seem to impact functionality. The performance seems excellent (way better than my i9 Intel laptop). I will do some more testing tomorrow.


Hey guys to install CmdStan 2.27 with CmdStanR in M1 Arm-based Macs you’ll probably have to pass the option ARCH in cpp_options:

install_cmdstan(cpp_options = list("ARCH" = "arm64"), cores = 4)

Thanks, @rok_cesnovar