我正在 Kaggle 中处理笔记本并尝试连接到 TPU。当我检查是否已使用此代码连接到 TPU 时:
AUTO = tf.data.experimental.AUTOTUNE
# Detect TPU, return appropriate distribution strategy
try:
tpu = tf.distribute.cluster_resolver.TPUClusterResolver()
print('Running on TPU ', tpu.master())
except ValueError:
tpu = None
if tpu:
tf.config.experimental_connect_to_cluster(tpu)
tf.tpu.experimental.initialize_tpu_system(tpu)
strategy = tf.distribute.TPUStrategy(tpu)
else:
strategy = tf.distribute.get_strategy()
print("REPLICAS: ", strategy.num_replicas_in_sync)
我得到的输出是这样的:
REPLICAS: 1
我不知道为什么我会得到这个..,当我必须获得总共 8 个副本时。
我该如何修复它?我的tensorflow版本是2.2.0。我尝试使用上一个版本,但得到相同的输出。
另外,我有以下信息,我不知道为什么:
为什么有一个‘?’在 TPU 中?
谢谢。期待您的答复。
同样的问题导入张量流时TPU已打开但不消耗