Dealing with Catalina II

Same for me, if I run @coatless as-is then I get sampling errors every now and then. But if I change .R/Makevars to

CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CPPFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include
SHLIB_CXXLDFLAGS+=-Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib
SHLIB_CXX11LDFLAGS+=-Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib
SHLIB_CXX14LDFLAGS+=-Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib

then it works.

3 Likes

Ok not a specific Catalina question here but as I’m thinking to buy a new macbook pro - going forward will Stan GPU acceleration continue to work on Mac now that day have deprecated OpenCl in favour of Metal2?

I hope this question isn’t out of place here I didnt’ think it merited a new thread.

The question is really out of place here… but to my understanding is that its very uncertain that GPU support will be there on Mac in the future given that OpenCL support is dropped. The hope is to find some adaptor software which handles this though. There are some discussions scattered on the forum.

1 Like

I think Sebastian mostly answered your question. Just to add a bit more context, though this might be a bit offtopic.

The only currently supported compute language on recent MacOSes is Metal. The only other non-fully-experimental way of doing GPU computing on a Mac is using Vulkan Compute and then translating that to metal with MoltenVK.

There is no OpenCL support as well as no CUDA support. Well NVIDIA GPUs dont even have drivers for Macs. There is an experimental translator from OpenCL to Vulkan which could then be tranlslate to Metal. But that all seems very bizzare.

The bigger isssue is that Metal has no double-precision floating point support which makes is really not suitable for Stan.

The only real hope for Stan GPU on a Mac is that Apple adds back suport for OpenCL or that they add support for OpenCL-Next or SYCL or even CUDA in the future.

1 Like

Hello! I am trying to run rstanarm on my MacBook Pro (Catalina). I appear to be running into the same issues listed in forums previously, but can’t make any of the suggested fixes fix my problem. I have downloaded and successfully installed the latest installer, updated R, RStudio, and my Mac (running 10.15.1), and restarted, re-downloaded, and rebooted as suggested. When running stan_lmer, I still come up with the same error message after the first chain:

[1] “Error in sampler$call_sampler(args_list[[i]]) : "
[2] " c++ exception (unknown reason)”
error occurred during calling the sampler; sampling not done

And then at the close of several failed chains:
[[4]]
Stan model ‘continuous’ does not contain samples.
Error in check_stanfit(stanfit) :
Invalid stanfit object produced please report bug
In addition: Warning messages:
1: In .local(object, …) :
some chains had errors; consider specifying chains = 1 to debug
2: In .local(object, …) :
some chains had errors; consider specifying chains = 1 to debug
Error in dimnamesGets(x, value) :
invalid dimnames given for “dgCMatrix” object

Any help you can offer would be greatly appreciated. My code and example code works just fine on my PC. Thanks so much for your time. -Amy

For rstanarm, at the moment, you have to reinstall it from source with

install.packages("rstanarm", type = "source")

Thanks Ben- unfortunately, both rstan and rstanarm are indeed installed from source. I just re-installed again just to be sure, but receive the same error.

Can you try installing rstanarm from source again after adding

CXX14 = /usr/local/clang7/bin/clang++ -stdlib=libc++ -nostdinc++ -I/usr/local/clang7/include/c++/v1
SHLIB_CXX14LD = /usr/local/clang7/bin/clang++ -L/usr/local/clang7/lib/

to ~/.R/Makevars ?

Hey guys - this thread has become very confusing for those of us dealing with this issue for the first time. There are a lot of recommended code snippets, but its very hard to tell what makes them different from each other, or whether any of them are worth trying at this point, etc.

Since this is a widespread issue, I want to suggest that it would be helpful for the community if someone knowledgeable put up a page, perhaps on the git, explaining the situation, and describing the current state of potentially effective workarounds, if there are any.

(BTW - the same issue arises with llvm9 installed by homebrew.)

6 Likes

The one at the top post is the recommended one when compiling your own Stan programs. We still don’t know what to do about packages that come with Stan models because the way they are linked on CRAN does not work when the user has Catalina.

@bgoodri The advice at the top of the thread (use the coatless installer to point the C include flags to XCode) did not fix building Stan models for me. (Possibly because XCode has been updated since R was compiled? Perhaps it would make sense to experiment with different XCode versions?) I think several other people have given the same comment.

I wasn’t aware that the latest Xcode update broke the solution to the breakage of the previous Xcode update. @coatless ? @ssp3nc3r ?

Just to be clear - I’m not saying the new XCode broke the fix. I’m just saying the fix didn’t work for me. The new XCode version was a guess about a possible cause. There seem to be other people in this and the other thread saying that the fix didn’t work.

Just to quickly confirm: I’m running the latest version of Xcode on my Catalina Mac (i.e. Software Update doesn’t show any updates and xcode-select --install doesn’t give me anything new) and my non-trivial Stan model is compiling and sampling just fine.

@Amos, I used @coatless installation script and then changed .R/Makevars to:

CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

CPPFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include

SHLIB_CXXLDFLAGS+=-Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib

SHLIB_CXX11LDFLAGS+=-Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib

SHLIB_CXX14LDFLAGS+=-Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib

On Catalina 10.15.1, R 3.6.1 (and RStudio 1.2.5019) everything works smoothly. I’ve been sampling happily for a week now :)

9 Likes

That did it! Once I figured out how to unhide files on my Mac to edit Makevars… : ) Thanks!

1 Like

How you managed to do that? For me it denies changes I try to make to that file.

@Ptterz, try to open a terminal and edit the file like this (Ctrl-X to exit and then save):
```nano ~/.R/Makevars``

I tried to do that when I found out your solution, but when I tried to save and exit, it denied changes.

Go to the directory ~/.R and type

chmod 644 Makevars