Issue
Since Monday or Thuesday this week (10.03.2025) the Google Colab TPUs are not found anymore.
Can someone help me please?
I am using
These are my resources
Sie haben Colab Pro abonniert. Weitere Informationen
Verfügbar: 55.47 Recheneinheiten
Nutzungsrate: ca. 3.66 pro Stunde
Sie haben 4 aktive Sitzungen.
This is my code
# 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)
Output: Connecting to TPU... TPU not found. Falling back to CPU/GPU strategy. Using distribution strategy: _DefaultDistributionStrategy Number of replicas: 1 Mixed Precision enabled: <DTypePolicy "mixed_bfloat16">
I tried dto switch the run time types back- and forward including saving them, restarting the sessions, logging in and out of the Google colab account.
I except to get the TPU found and up and running like last week.
This solution works for me:
!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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With