完成后如何杀死一个doMC员工? [英] How to kill a doMC worker when it's done?
本文介绍了完成后如何杀死一个doMC员工?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
库(doMC)
库(foreach)
registerDoMC(32)
foreach(i = 1:32)%dopar%foo()
## kill命令在这里?
我尝试了registerDoSEQ(),但似乎并没有关闭进程。
解决方案
我从来没有找到适合于doMC的解决方案,所以有一段时间我一直在做以下工作:
library(doParallel)
cl < - makePSOCKcluster(4)#要使用的内核数量
registerDoParallel(cl )
##计算
stopCluster(cl)
每次工作。
The documentation for doMC seems very sparse, listing only doMC-package and registerDoMC(). The problem I'm encountering is I'll spawn several workers via doMC/foreach, but then when the job is done they just sit there taking up memory. I can go and hunt their process IDs, but I often kill the master process by accident.
library(doMC)
library(foreach)
registerDoMC(32)
foreach(i=1:32) %dopar% foo()
##kill command here?
I've tried following with registerDoSEQ() but it doesn't seem to kill off the processes.
解决方案
I never did find a suitable solution for doMC, so for a while I've been doing the following:
library(doParallel)
cl <- makePSOCKcluster(4) # number of cores to use
registerDoParallel(cl)
## computation
stopCluster(cl)
Works every time.
这篇关于完成后如何杀死一个doMC员工?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文