bill.lihan
bill.lihan

Reputation: 31

Rstan error with Apple M1 chip in Mac OSX Montery/Ventura: "unknown target CPU 'apple-m1'"

I have been having trouble running rstan on my Macbook Pro since I updated to OSX 12. I have tried updating R, RStudio, rstan, XCode, OSX, and the problem persisted. Initially, the error was something along the line of "march=native not supported". Now with all the updates, the error became

Error in compileCode(f, code, language = language, verbose = verbose) : 
      #pragma clang diagnostic pop                             ^18 warnings generated.error: unknown target CPU 'apple-m1'note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, x86-64-v2, x86-64-v3, x86-64-v4make: *** [file32ac3ef1d6.o] Error 1

Now, when I typed "clang --print-supported-cpus" into the Terminal, "apple-m1" did show up, so I suspect it's simply a matter of rstan using the wrong versions/options of things for the compilation. I took a look at my /.R/Makevars file, and it says

CXX14FLAGS=-O3 -march=native -mtune=native
CXX14FLAGS += -arch x86_64 -ftemplate-depth-256
CPPFLAGS="-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"

I tried messing around with the file, by deleting things, adding "mcpus=apple-m1", and various other ill-informed shenanigans. I got various results including the same error message, crashing rstan (and R), and compiling the model but running into the message "Error in unserialize(socklist[[n]]) : error reading from connection". I feel I'm completely out of my depth at this point, and I could use some help from someone more familiar with C++ and such.

Thanks a ton in advance!

Upvotes: 3

Views: 636

Answers (0)

Related Questions