Error in loo::relative_eff( ) related to options( mc.cores )

Operating System: Windows 10
Interface Version: R 2.5.1 / RStudio 1.1.453 / loo 2.0.0


I’m running into an issue where if I utilize options(mc.cores = parallel::detectCores()) (for rstan), and then run:

loo::relative_eff( exp( example_loglik_array() ) )

I get the following error:

Error in checkForRemoteErrors(val) : 8 nodes produced errors; first error: could not find function "mcmc_n_eff"

I ran into this, initially, using RStudio, but the issue can also be reproduced in basic R 3.5.1. Also, the function works fine so long as I don’t first set the options for mc.cores.

Sorry, if this has been posted before or if I’m just missing something obvious. This is my first whack at utilizing the ‘loo’ package.




Seems obvious now, but it turns out that the error was related to the number of cores specified for use for parallelization in the relative_eff() call.

I have 8 cores according to parallel::detectCores(), which was what was then set in the options(mc.cores = parallel::detectCores()) statement I used at the beginning of my R code for working with rstan. So then, when I executed relative_eff() without specifying the number of cores to use in the options for that call, it looks like it defaults to getOption("mc.cores", 1), according to the R help. So, i was asking relative_eff() to use 8 cores in the calculation I guess.

I’ve since realized that all works fine, even if I set options(mc.cores = parallel::detectCores()) for rstan at the beginning of my analysis code, so long as I make sure that the cores option is set to 1, or relative_eff( ... , cores = 1 ). Anything greater than 1 for cores doesn’t work, which I admit I’m not entirely sure why, but I’ve just started learning about loo. This is also true for the loo call, itself, where I have to specifically set cores to 1, such that loo( ..., cores = 1). All in all, I think this might have been less confusing were it not for the initial error message thrown, which wasn’t entirely intuitive to me, though the 8 nodes produced errors part should have maybe been telling.

Nevertheless, I think I can move on, and I look forward to using and learning loo!

Thanks again,


Hi @royworth,
I am also learning to use loo() and I admit that I am also having trouble to compute relative_eff() if I specified cores to any number other than 1.

1 Like