如何在Tensorflow 2.0中连接到远程集群?

问题描述 投票:0回答:1

在Tensorflow 1.x中,有一种使用tf.contrib.distribute.DistributeConfig将Estimator连接到远程集群的方法,如Tensorflow生态系统存储库中的this example code所示。

Tensorflow 2.0引入了实验性MultiWorkerMirroredStrategy,并更改了RunConfig的实现,以使用TF_CONFIG环境变量来设置集群。但是,这要求当前执行的代码成为该群集的一部分,即,必须在task中设置TF_CONFIG。如果您尝试将客户端计算机连接到远程群集,那么这当然没有任何意义。

有人知道在Tensorflow 2.0中是否有等效的方法来实现这一目标?我一直在寻找时间,而我能想到的最好的办法是通过调用tf.compat.v1.Session('grpc://[cluster-ip]:[cluster-port]')进行连接,然后使用v1 compat API进行设置。这不理想,因为我们不仅使用了已弃用的API,而且似乎失去了在多个工作线程之间分配的功能(Session一次仅连接到一个节点)。

tensorflow keras distributed-computing tensorflow2.0 tensorflow-estimator
1个回答
0
投票

您可以通过以下方式创建MultiWorkerMirroredStartegy

multiworker_strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy()

为此,您还需要使用TF_CONFIG配置多工设置

© www.soinside.com 2019 - 2024. All rights reserved.