英文:
How to close additional R sessions when parallel computing is completed using doFuture package?
问题
我正在尝试使用doFuture
包进行并行计算。以下是该包文档中的代码。
library(doFuture)
plan(multisession)
cutoff <- 0.10
y <- foreach(x = mtcars) %dofuture% {
mean(x, trim = cutoff)
}
names(y) <- colnames(mtcars)
当计算完成时,用于并行计算的额外R会话没有关闭。当我使用doParallel
包时,我使用以下代码创建集群:
cl <- makeCluster(cores)
registerDoParallel(cl)
并使用以下代码停止集群:
closeCluster(cl)
在使用doFuture
包时,如何关闭这些R会话呢?
英文:
I'm trying to use doFuture
package for parallel computing. Here is the code from the document of the package.
library(doFuture)
plan(multisession)
cutoff <- 0.10
y <- foreach(x = mtcars) %dofuture% {
mean(x, trim = cutoff)
}
names(y) <- colnames(mtcars)
When the computing is completed, the additional R sessions for parallel computing are not closed. When I use doParallel
package, I use the following to make cluster
cl <- makeCluster(cores)
registerDoParallel(cl)
and use the following code to stop cluster.
closeCluster(cl)
How do I close these R sessions when using the doFuture
package?
答案1
得分: 2
将计划设置为sequential()
将关闭额外的R会话。
英文:
Setting the plan to sequential()
will close the extra R sessions.
plan(sequential)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论