本文整理汇总了Python中tensorflow.contrib.cluster_resolver.python.training.tpu_cluster_resolver.TPUClusterResolver.get_master方法的典型用法代码示例。如果您正苦于以下问题:Python TPUClusterResolver.get_master方法的具体用法?Python TPUClusterResolver.get_master怎么用?Python TPUClusterResolver.get_master使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.contrib.cluster_resolver.python.training.tpu_cluster_resolver.TPUClusterResolver
的用法示例。
在下文中一共展示了TPUClusterResolver.get_master方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testGetMasterNoEntries
# 需要导入模块: 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 get_master [as 别名]
def testGetMasterNoEntries(self):
tpu_map = {}
tpu_cluster_resolver = TPUClusterResolver(
project='test-project',
zone='us-central1-c',
tpu_names=[],
credentials=None,
service=self.mock_service_client(tpu_map=tpu_map))
with self.assertRaises(ValueError):
tpu_cluster_resolver.get_master()
示例2: testGkeEnvironment
# 需要导入模块: 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 get_master [as 别名]
def testGkeEnvironment(self):
os.environ['KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS'] = 'grpc://10.120.27.5:8470'
self.assertTrue('KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS' in os.environ)
tpu_cluster_resolver = TPUClusterResolver()
self.assertTrue(tpu_cluster_resolver._inGke())
self.assertEqual(
compat.as_bytes('grpc://10.120.27.5:8470'),
compat.as_bytes(tpu_cluster_resolver._gkeMaster()))
self.assertEqual(
compat.as_bytes('grpc://10.120.27.5:8470'),
compat.as_bytes(tpu_cluster_resolver.get_master()))
del os.environ['KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS']
示例3: testGetMasterMultipleEntries
# 需要导入模块: 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 get_master [as 别名]
def testGetMasterMultipleEntries(self):
tpu_map = {
'projects/test-project/locations/us-central1-c/nodes/test-tpu-1': {
'ipAddress': '10.1.2.3',
'port': '8470'
},
'projects/test-project/locations/us-central1-c/nodes/test-tpu-2': {
'ipAddress': '10.4.5.6',
'port': '8470'
}
}
tpu_cluster_resolver = TPUClusterResolver(
project='test-project',
zone='us-central1-c',
tpu_names=['test-tpu-2', 'test-tpu-1'],
credentials=None,
service=self.mock_service_client(tpu_map=tpu_map))
self.assertEqual('grpc://10.4.5.6:8470', tpu_cluster_resolver.get_master())