How to run stan:glmer in parallel on windows?

  • Operating System: Windows 10
  • rstanarm Version: 2.19.2 2019-10-03 [1] CRAN (R 3.6.1)

Hi all, I’m struggling to find any info on how to run a glmer model in parallel on windows. It looks like Macs have the simple solution of running:
“options(MC.cores=parallel::detectCores())”, but this won’t help on windows.

I’ve opened a cluster (following here: http://dept.stat.lsa.umich.edu/~jerrick/courses/stat701/notes/parallel.html#using-sockets-with-parlapply), but now I don’t know how to run my MCMC chains in parallel.

Any guidance/suggestions?

If relevant, my model looks like this:

mdl <- rstanarm::stan_glmer(acc_num ~ T_excl1_state * total_trial_num_sc + final_Q_Tacc + (1|participant), data = subset(as.data.frame(dat), label == ‘NT’), family = ‘binomial’)

That works on Windows too. It will parallelize the chains.

Just a quick check: shouldn’t this be options(mc.cores = (lowercase mc)? That could explain if it’s not working for you (it definitely should work on Windows - I am on Windows and use it all the time)

Right. Lowercase.

In 4 years of coding, this is the first time I’ve ever had to ask a question in a forum.

Indeed, lowercase “mc.cores” does it.

For what its worth, I ran benchmark() with mc.cores set to 2 vs detectCores (4 cores for me) and it was faster with detectCores (elapsed == 447, vs 652)

Thanks for clarifying for me! :)

2 Likes