"Anular el registro" de un clúster doParallel
Si corroforeach... %dopar%
sin registrar un clúster, foreach genera una advertencia y ejecuta el código secuencialmente:
library("doParallel")
foreach(i=1:3) %dopar%
sqrt(i)
Rendimientos:
Warning message:
executing %dopar% sequentially: no parallel backend registered
Sin embargo, si ejecuto este mismo código después de iniciar, registrar y detener un clúster, falla:
cl <- makeCluster(2)
registerDoParallel(cl)
stopCluster(cl)
rm(cl)
foreach(i=1:3) %dopar%
sqrt(i)
Rendimientos:
Error in summary.connection(connection) : invalid connection
¿Hay un opuesto deregisterDoParallel()
que limpia el registro del clúster? ¿O estoy atrapado con el fantasma del antiguo clúster hasta que reinicie mi sesión R?
/ edit: algunas búsquedas en Google revelanbumphunter:::foreachCleanup()
funcionar en elbumphunter Paquete biocondoctor:
function ()
{
if (exists(".revoDoParCluster", where = doParallel:::.options)) {
if (!is.null(doParallel:::.options$.revoDoParCluster))
stopCluster(doParallel:::.options$.revoDoParCluster)
remove(".revoDoParCluster", envir = doParallel:::.options)
}
}
<environment: namespace:bumphunter>
Sin embargo, esta función no parece solucionar el problema.
library(bumphunter)
cl <- makeCluster(2)
registerDoParallel(cl)
stopCluster(cl)
rm(cl)
bumphunter:::foreachCleanup()
foreach(i=1:3) %dopar%
sqrt(i)
¿Dónde guarda foreach la información en el grupo registrado?