google colab tpu突然找不到了

问题描述 投票:0回答:0

issue

本周星期一或thuesday(10.03.2025)不再找到Google Colab TPU。

有人可以帮我吗?

我正在使用

TensorFlow版本:2.18.1

Keras-tuner版本:1.4.7
  • 这些是我的资源
  • Sie haben Colab Pro abonniert. Weitere Informationen Verfügbar: 55.47 Recheneinheiten Nutzungsrate: ca. 3.66 pro Stunde Sie haben 4 aktive Sitzungen.

这是我的代码

# TPU Strategy Setup
try:
    print("Connecting to TPU...")
    tpu = tf.distribute.cluster_resolver.TPUClusterResolver()  # Resolving TPU cluster
    tf.config.experimental_connect_to_cluster(tpu)
    tf.tpu.experimental.initialize_tpu_system(tpu)
    print("TPU initialized successfully!")
    strategy = tf.distribute.TPUStrategy(tpu)  # TPU strategy definition
except ValueError:
    print("TPU not found. Falling back to CPU/GPU strategy.")
    strategy = tf.distribute.get_strategy()  # Default CPU/GPU strategy

# Confirm strategy definition
if 'strategy' not in locals():
    raise RuntimeError("TPU strategy setup failed. Please check TPU initialization.")

# Log TPU Configuration
print(f"Using distribution strategy: {strategy.__class__.__name__}")
print(f"Number of replicas: {strategy.num_replicas_in_sync}")

tf.debugging.set_log_device_placement(True)

# Enable Mixed Precision for TPU optimization
policy = mixed_precision.Policy('mixed_bfloat16')
mixed_precision.set_global_policy(policy)
print("Mixed Precision enabled: ", policy)

输出: 连接到TPU ... 找不到TPU。回到CPU/GPU策略。 使用分销策略:_DEFAULTDISTRIBITYSTRATEGY 复制品数:1 启用混合精度:

i我尝试了DTO切换运行时间类型,包括保存它们,重新启动会话,登录和登录Google Colab帐户。
我除了在上周像找到TPU一样启动和运行。
    

该解决方案对我有用:

!pip install tensorflow==2.18.0 !pip install tensorflow-tpu==2.18.0 --find-links=https://storage.googleapis.com/libtpu-tf-releases/index.html import tensorflow as tf try: tpu = tf.distribute.cluster_resolver.TPUClusterResolver(tpu='local') tf.config.experimental_connect_to_cluster(tpu) tf.tpu.experimental.initialize_tpu_system(tpu) strategy = tf.distribute.TPUStrategy(tpu) print("TPU is running:", tpu.master()) except ValueError as e: print("TPU is not avaible:", e)

tensorflow google-colaboratory tpu keras-tuner
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.