question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FLAX-T5 - TPU not found Colab

See original GitHub issue

Hello, I’m using the code run_t5_mlm_flax.py on Google Colab in TPU mode.

I have the following problem: image And also: /usr/local/lib/python3.7/dist-packages/jax/__init__.py:27: UserWarning: cloud_tpu_init failed: ConnectionError(MaxRetryError("HTTPConnectionPool(host='metadata.google.internal', port=80): Max retries exceeded with url: /computeMetadata/v1/instance/attributes/agent-worker-number (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4ff0494790>: Failed to establish a new connection: [Errno 110] Connection timed out'))")) This a JAX bug; please report an issue at https://github.com/google/jax/issues _warn(f"cloud_tpu_init failed: {repr(exc)}\n This a JAX bug; please report "

The TPU is not found, and the code switch in CPU mode. I’m using these libraries: pip install datasets pip install transformers pip install flax pip install optax

and also this configuration I read: import jax.tools.colab_tpu jax.tools.colab_tpu.setup_tpu() print(jax.local_devices()) export XRT_TPU_CONFIG="localservice;0;localhost:51011" unset LD_PRELOAD USE_TORCH=0

How can I do to use this code on Colab or to use a FLAX-T5 with TPU on Colab?

Thank you!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
patil-surajcommented, May 11, 2022

Found the issue. We need to call

import jax.tools.colab_tpu
jax.tools.colab_tpu.setup_tpu()

in the script before importing anything JAX related. Calling setup_tpu() in the colab and then launching the script won’t work because these are two different processes. So adding these two lines in the script before any JAX/Flax import should fix this issue.

0reactions
0syryscommented, May 12, 2022

@patil-suraj Thanks that’s it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorials for using Colab TPUs with Huggingface Transformers?
I looking for an easy-to-follow tutorial for using Huggingface Transformer models (e.g. BERT) in PyTorch on Google Colab with TPUs. I found ......
Read more >
Why is TPU on Google Colab in PyTorch not being detected?
I set my hardware accelerator to TPU. This line of code shows that no cuda device is being detected: device = torch.device('cuda:0' if...
Read more >
Huggingface t5 example
But I can`t find a list of many tasks it really supports and how to nlp ... a FlaxT5 model from HuggingFace using...
Read more >
Model Zoo - Deep learning code and pretrained models for ...
ModelZoo curates and provides a platform for deep learning researchers to easily find code and pre-trained models for a variety of platforms and...
Read more >
T5 on TPU - Colaboratory - Google Colab
In this notebook we will see how to train T5 model on TPU with Huggingface's awesome new trainer. ... This will not work...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found