Dealing with Catalina

Maybe. But Rcpp::sourceCpp and inline::cxxfunction are loading the DLLs automatically, so I don’t see how those would ever work on a Catalina machine. Prior to Catalina, rstan was working with essentially

  1. inline::cxxfunction
  2. install_name_tool ...
  3. dyn.unload(path)
  4. dyn.load(path)

Does the new Stan release solve this issue or is Catalina still causing problems?

Unlikely

Hello, I am a new Stan user and just want to echo that I am having the exact same issue as other people here. It seems like conversation on this thread has fallen off in the past few days - was a permanent, consistent solution ever found? Thanks.

No.

Not yet but @bgoodri and others are working on it!

If you want to try running Stan from R a different way in the meantime this might work:

1 Like

I use Docker for now, and it works nicely :)

https://cloud.docker.com/repository/docker/torkar/rstan

Install via the terminal by writing (on one line):

docker run -e PASSWORD=YOURPASSWORD -p 8787:8787 -v /PATH/TO/YOUR/HOMEDIR:/home/rstudio torkar/rstan:latest

Change YOURPASSWORD and /PATH/TO/YOUR/HOMEDIR. Point your browser to localhost:8787.

2 Likes

Docker is the only way I can work right now on the machines I “upgraded” to Catalina. It’s just amazing that Apple has bricked so many people. I have several friends who just can’t work until there is a simple solution.

I tried to load blavaan earlier today and got an error - adding it in case it points to a solution

library(blavaan)
Loading required package: Rcpp
Error: package or namespace load failed for ‘blavaan’ in dyn.load(file, DLLpath = DLLpath, …):
unable to load shared object ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/quantreg/libs/quantreg.so’:
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/quantreg/libs/quantreg.so, 6): Library not loaded: /usr/local/gfortran/lib/libgfortran.5.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/quantreg/libs/quantreg.so
Reason: image not found
install.packages(“blavaan”)
Installing package into ‘/Users/lukemansillo/Library/R/3.6/library’
(as ‘lib’ is unspecified)
trying URL ‘http://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/blavaan_0.3-7.tgz
Content type ‘application/x-gzip’ length 10100210 bytes (9.6 MB)
==================================================
downloaded 9.6 MB
The downloaded binary packages are in
/var/folders/bx/8ltnl1nd13b3k8vjzl8m7ffw0000gn/T//RtmpEpxFYL/downloaded_packages
library(blavaan)
Error: package or namespace load failed for ‘blavaan’ in dyn.load(file, DLLpath = DLLpath, …):
unable to load shared object ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/quantreg/libs/quantreg.so’:
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/quantreg/libs/quantreg.so, 6): Library not loaded: /usr/local/gfortran/lib/libgfortran.5.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/quantreg/libs/quantreg.so
Reason: image not found

For transparency: I posted about the issues with Catalina on official Stan Twitter so that users are warned. If you think I’ve mischaracterized the situation, let me know and I will update the info there (people with access to official Twitter can obviously do it themselves).

Wish you good luck with hunting this down.

4 Likes

@torkar I just installed Docker ran a brms job with it but the error emerged for one of the chains:

m_demos_secular_age ← brm(auth_theta_st |weights(weight)~ s(age,by=religion_sample),family=gaussian(),
data=survey_data,
cores = 4,chains=4, iter = 5000,
file=“models/m_demos_secular_age”)
Compiling the C++ model
recompiling to avoid crashing R session
Start sampling
starting worker pid=1162 on localhost:11460 at 01:37:30.530
starting worker pid=1176 on localhost:11460 at 01:37:30.722
starting worker pid=1190 on localhost:11460 at 01:37:30.911
starting worker pid=1204 on localhost:11460 at 01:37:31.099
SAMPLING FOR MODEL ‘0c266c38e0747884b21cf03aad6cbcc2’ NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 0.00253 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 25.3 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1:
Chain 1:
Chain 1: Iteration: 1 / 5000 [ 0%] (Warmup)
SAMPLING FOR MODEL ‘0c266c38e0747884b21cf03aad6cbcc2’ NOW (CHAIN 2).
Chain 2:
Chain 2: Gradient evaluation took 0.002729 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 27.29 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2:
Chain 2:
Chain 2: Iteration: 1 / 5000 [ 0%] (Warmup)
SAMPLING FOR MODEL ‘0c266c38e0747884b21cf03aad6cbcc2’ NOW (CHAIN 3).
Chain 3:
Chain 3: Gradient evaluation took 0.003116 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 31.16 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3:
Chain 3:
[1] “Error in sampler$call_sampler(args_list[[i]]) : "
[2] " c++ exception (unknown reason)”
error occurred during calling the sampler; sampling not done
SAMPLING FOR MODEL ‘0c266c38e0747884b21cf03aad6cbcc2’ NOW (CHAIN 4).
Chain 4:
Chain 4: Gradient evaluation took 0.002956 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 29.56 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4:
Chain 4:
Chain 4: Iteration: 1 / 5000 [ 0%] (Warmup)

Am I possibly doing/done something wrong? Have you had success sampling with each implementation of rstan? Does this extend to brms or any other package such as blavaan that acts as a wrapper for RStan?

You are running this on localhost:8787?!? I, and others, have used the Docker image now for a number of days and I haven’t seen that error on Docker :( Can you send a MWE (incl. data) that I can try to run to see what happens?

I was hoping it could be that I was doing something wrong since I’m unfamiliar with much computer science. What do you mean by running it on localhost:8787 exactly?

@torkar I downloaded the Docker desktop app, ran the code you posted, I put localhost:8787 into Chrome an RStudio login appeared; I couldn’t log in, didn’t know what credentials it was after, I guessed it was the credentials I had made to download the Docker desktop app.

I’m clearly way out of my depth but I need to get RStan and its implementation through brms back in action.

@mansillo, in case there are more questions regarding Docker please start a new thread/question so we keep this separate from the issues in this forum.

Login using rstudio and the password you set when starting your docker image.

Has anyone tried g++ on Catalina, which you would have to download presumably?

Thanks, @Jonah. I am able to get cmdstanr to work correctly on stan models on Catalina after removing the .Renviron that sets the path to clang7, which I think was created as part of the @coatless instructions for rstan. I also removed the .Makevars file, so rstan is just using the apple clang compiler, but that may not have been needed for cmdstanr anyway. So this looks like at least a great interim option.

2 Likes

I upgraded to Catalina last week and rstan along with git was not working.

I ran xcode-select --install on the command line and it fixed the problem for me.

I got the solution from this link: https://apple.stackexchange.com/questions/254380/why-am-i-getting-an-invalid-active-developer-path-when-attempting-to-use-git-a

2 Likes

It might be interesting to see if PyStan on Catalina faces the same problems as RStan. One might think that it should, but given that I’ve seen other circumstances where PyStan worked but RStan failed, that’s far from guaranteed. If Catalina affects the two Stan interfaces differently, it may help narrow down the source of the problem.

A couple of notes:

  1. Using clang7 means having two copies of the libc++. The benefit of the second libc++ and clang7 compiler is access to OpenMP methods. Thus, when the clang7 compiler is removed from the PATH variable in .Renviron there is a loss of OpenMP compatibility. Again, mileage may vary for Stan, but this does go against the standard configuration. Perhaps two sets of installers are required?
  2. Deleting the ~/R/.Makevars file makes little sense as there must be variables set for the new location of the C header files in macOS Catalina.