I’m having some trouble with the within-chain parallelization with the developmental release of brms. When I run the Poisson example model from https://cran.r-project.org/web/packages/brms/vignettes/brms_threading.html,
I get the following error:
> set.seed(54647)
> # number of observations
> N <- 1E4
> # number of group levels
> G <- round(N / 10)
> # number of predictors
> P <- 3
> # regression coefficients
> beta <- rnorm(P)
>
> # sampled covariates, group means and fake data
> fake <- matrix(rnorm(N * P), ncol = P)
> dimnames(fake) <- list(NULL, paste0("x", 1:P))
>
> # fixed effect part and sampled group membership
> fake <- transform(
+ as.data.frame(fake),
+ theta = fake %*% beta,
+ g = sample.int(G, N, replace=TRUE)
+ )
>
> # add random intercept by group
> fake <- merge(fake, data.frame(g = 1:G, eta = rnorm(G)), by = "g")
>
> # linear predictor
> fake <- transform(fake, mu = theta + eta)
>
> # sample Poisson data
> fake <- transform(fake, y = rpois(N, exp(mu)))
>
> # shuffle order of data rows to ensure even distribution of computational effort
> fake <- fake[sample.int(N, N),]
>
> # drop not needed row names
> model_poisson <- brm(
+ y ~ 1 + x1 + x2 + (1 | g),
+ data = fake,
+ family = poisson(),
+ iter = 100, # short sampling to speedup example
+ prior = prior(normal(0,1), class = b) +
+ prior(constant(1), class = sd, group = g),
+ backend = "cmdstanr",
+ threads = threading(2)
+ )
Compiling Stan program...
error: PCH file built from a different branch ((clang-1200.0.32.2)) than the compiler ((clang-1200.0.32.21))
1 error generated.
make: *** [/var/folders/_7/hwwgxng55r757tl4cmxg0q7w0000gp/T/RtmpxyRu95/model-1f8f588b5969] Error 1
Error: An error occured during compilation! See the message above for more information.
Any suggestions on what I might adjust in my settings to get this running?
For reference:
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] brms_2.14.2 Rcpp_1.0.5
> cmdstan_version()
[1] "2.24.1"
Thanks for your help. Scott