使用doParallel时如何获取节点或进程ID? [英] How do I get node or process id when using doParallel?
本文介绍了使用doParallel时如何获取节点或进程ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在12个节点的群集上运行并行进程.
I am running a parallel process on a 12 node cluster.
并且想知道在foreach
调用期间是否可以获取节点ID或节点号或节点名?
And was wondering if there is a way to get the node-id or node-number or node-name during a foreach
call?
类似这样的东西:
foreach(i = 1:12, .combine=c) %dopar% {node.name()}
这将有助于处理文件.
推荐答案
经过反复试验,我发现以下方法可以工作:
After a lot of trial and error, I found the following to work:
foreach(i = 1:12, .combine=c) %dopar% {
Sys.getpid()
}
这为每个节点提供了唯一的进程ID,可用作节点ID.
This gives a unique process ID for each of the nodes, which can be used as the node id.
这篇关于使用doParallel时如何获取节点或进程ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文