I am trying to connect to TPU and run inference in google colab with the following code:…
- User
I am trying to connect to TPU and run inference in google colab with the following code:
import tensorflow as tf import keras_nlp import os tpu_resolver = tf.distribute.cluster_resolver.TPUClusterResolver.connect() tpu = tf.tpu.experimental.initialize_tpu_system(tpu_resolver) # TPU detection tf.config.experimental_connect_to_cluster(tpu) tf.tpu.experimental.initialize_tpu_system(tpu) strategy = tf.distribute.TPUStrategy(tpu) with strategy.scope(): gemma = keras_nlp.models.GemmaCausalLM.from_preset("gemma3_1b") output = gemma.generate("Keras is a", max_length=30) print(output)But I get the following error:
ValueError Traceback (most recent call last) <ipython-input-15-7a705b107179> in <cell line: 0>() 3 import os # Import os for TPU check 4 ----> 5 tpu_resolver = tf.distribute.cluster_resolver.TPUClusterResolver.connect() 6 tpu = tf.tpu.experimental.initialize_tpu_system(tpu_resolver) # TPU detection 7 2 frames /usr/local/lib/python3.11/dist-packages/tensorflow/python/tpu/client/client.py in __init__(self, tpu, zone, project, credentials, service, discovery_url) 157 zone = zone or tpu_node_config.get('zone') 158 else: --> 159 raise ValueError('Please provide a TPU Name to connect to.') 160 161 self._tpu = _as_text(tpu) ValueError: Please provide a TPU Name to connect to.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.