2

当我运行以下 .ipynb 时:

https://colab.research.google.com/drive/1DpUCBm58fruGNRtQL_DiSVbT90spdZgm

我有:

没有注册 OpKernel 以支持节点 TPUReplicateMetadata 使用的 Op 'TPUReplicateMetadata'(在 /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py:1748 定义)具有以下属性:[num_cores_per_replica =1,use_tpu=true,num_replicas=8,computation_shape=[],host_compute_core=[],device_assignment=[],_tpu_replicate="cluster",padding_map=[],topology="",step_marker_location="STEP_MARK_AT_ENTRY",allow_soft_placement= false] 注册设备:[CPU, XLA_CPU]

我已经在 github 中问过这个问题: https ://github.com/tensorflow/tensorflow/issues/33307

但开发商表示不允许问这样的问题。

非常感谢您的帮助~!

4

1 回答 1

0

您应该遵循本教程:https ://cloud.google.com/tpu/docs/quickstart (您必须创建一个 GCP 帐户)并设置一个 Cloud TPU。然后您必须单击运行时并将“TPU”设置为硬件加速器。

最后,您应该将此代码添加到您的 colab 笔记本中:

import tensorflow as tf
import pprint

assert 'COLAB_TPU_ADDR' in os.environ, 'ERROR: Not connected to a TPU runtime; please see the first cell in this notebook for instructions!'
TPU_ADDRESS = 'grpc://' + os.environ['COLAB_TPU_ADDR']
print('TPU address is', TPU_ADDRESS)

from google.colab import auth
auth.authenticate_user()

with tf.compat.v1.Session(TPU_ADDRESS) as session:
  print('TPU devices:')
  pprint.pprint(session.list_devices())

  # Upload credentials to TPU.
  with open('/content/adc.json', 'r') as f:
    auth_info = json.load(f)
  tf.contrib.cloud.configure_gcs(session, credentials=auth_info)
  # Now credentials are set for all future sessions on this TPU.
于 2020-12-19T08:22:23.840 回答