本文整理汇总了Python中tensorflow.contrib.cluster_resolver.python.training.tpu_cluster_resolver.TPUClusterResolver._gkeEndpoints方法的典型用法代码示例。如果您正苦于以下问题:Python TPUClusterResolver._gkeEndpoints方法的具体用法?Python TPUClusterResolver._gkeEndpoints怎么用?Python TPUClusterResolver._gkeEndpoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.contrib.cluster_resolver.python.training.tpu_cluster_resolver.TPUClusterResolver
的用法示例。
在下文中一共展示了TPUClusterResolver._gkeEndpoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testGkeEnvironmentForPod
# 需要导入模块: from tensorflow.contrib.cluster_resolver.python.training.tpu_cluster_resolver import TPUClusterResolver [as 别名]
# 或者: from tensorflow.contrib.cluster_resolver.python.training.tpu_cluster_resolver.TPUClusterResolver import _gkeEndpoints [as 别名]
def testGkeEnvironmentForPod(self):
os.environ['KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS'] = ('grpc://10.120.27.5:8470,'
'grpc://10.120.27.6:8470,'
'grpc://10.120.27.7:8470,'
'grpc://10.120.27.8:8470')
self.assertIn('KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS', os.environ)
self.assertTrue(TPUClusterResolver._inGke())
self.assertEqual(
compat.as_bytes('grpc://10.120.27.5:8470,'
'grpc://10.120.27.6:8470,'
'grpc://10.120.27.7:8470,'
'grpc://10.120.27.8:8470'),
compat.as_bytes(TPUClusterResolver._gkeEndpoints()))
tpu_cluster_resolver = TPUClusterResolver()
self.assertEqual(
compat.as_bytes('grpc://10.120.27.5:8470'),
compat.as_bytes(tpu_cluster_resolver.master()))
actual_cluster_spec = tpu_cluster_resolver.cluster_spec()
expected_proto = """
job {
name: 'worker'
tasks { key: 0 value: '10.120.27.5:8470' }
tasks { key: 1 value: '10.120.27.6:8470' }
tasks { key: 2 value: '10.120.27.7:8470' }
tasks { key: 3 value: '10.120.27.8:8470' }
}
"""
self._verifyClusterSpecEquality(actual_cluster_spec, expected_proto)
del os.environ['KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS']