Error in Tensorflow 2.5.0 while using Colab TPU - NotFoundError: Could not find metadata file. [Op.DatasetCardinality]

Error in Tensorflow 2.5.0 while using Colab TPU - NotFoundError: Could not find metadata file. [Op.DatasetCardinality]

注意:这些相同的步骤在 Colab GPU 上没有任何错误。

请帮我解决这个问题。我创建了一个数据集并将其保存为文件

data = tf.data.Dataset.from_tensor_slices(( features, labels))
tf.data.experimental.save(data, myfile)

当我尝试加载它时

data = tf.data.experimental.load(myfile)

和 运行 数据上的任何函数,如 len(data)data.batch(16)data.take(1) 然后我得到这个错误:

NotFoundError: Could not find metadata file. [Op:DatasetCardinality]

TPU 配置

resolver = tf.distribute.cluster_resolver.TPUClusterResolver(tpu='')
tf.config.experimental_connect_to_cluster(resolver)
# This is the TPU initialization code that has to be at the beginning.
tf.tpu.experimental.initialize_tpu_system(resolver)

是否与此类似TF1.14][TPU]Can not use custom TFrecord dataset on Colab using TPU

经过更多调试后我得到了这个错误:

UnimplementedError: File system scheme '[local]' not implemented (file: './data/temp/2692738424590406024')
    Encountered when executing an operation using EagerExecutor. This error cancels all future operations and poisons their output tensors. [Op:DatasetCardinality]

我找到了这个解释:

云 TPU 只能访问 GCS 中的数据,因为只注册了 GCS 文件系统。

更多信息在这里: