我正在尝试在带有 TensorFlow 2.1 的 Google Cloud Compute Engine VM 上使用我的(抢占式)Cloud TPU v3-256,但它似乎无法正常工作TPUClusterResolver
抛出一个Could not lookup TPU metadata
error.
只要我使用单独的(非抢占式)TPU 就可以正常工作grpc://
地址而不是 TPU 名称。但是,在使用 TPU 名称时,单个 TPU 和我的 TPU Pod 都不起作用,并抛出此错误。
有人可以帮我解决这个问题吗?
Code:
resolver = tf.distribute.cluster_resolver.TPUClusterResolver(tpu='my-tpu-name', zone='europe-west4-a', project='my-project') # The zone, project and TPU Name are correct
Output:
ValueError: Could not lookup TPU metadata from name 'my-tpu-name'. Please double
check the tpu argument in the TPUClusterResolver constructor.
Exception: Failed to retrieve http://metadata.google.internal/computeMetadata/v1/
instance/service-accounts/default/?recursive=True
from the Google Compute Enginemetadata service. Response: {'metadata-flavor': 'Google',
'date': 'Thu, 28 May 2020 17:42:35 GMT', 'content-type': 'text/html; charset=UTF-8',
'server': 'Metadata Server for VM', 'content-length': '1629', 'x-xss-protection': '0', 'x
frame-options': 'SAMEORIGIN', 'status': '404'}
我怀疑这可能是以下任一方面不匹配:计算 VM 和 TPU 之间的 Tensorflow 版本、区域或项目。
如果您使用相同的 Tensorflow 版本(2.1 或 2.2)创建 TPU 和 GCE VM,并且它们都创建在同一项目和区域中。您只需提供 TPU 名称即可TPUClusterResolver
它应该工作正常:
resolver = tf.distribute.cluster_resolver.TPUClusterResolver(tpu='my-tpu-name')
如果设置,则可以省略 TPU 名称TPU_NAME
环境变量(export TPU_NAME=my-tpu-name
)在您的虚拟机上。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)