xla icon indicating copy to clipboard operation
xla copied to clipboard

Unable to run on Google Colab

Open BrandonStudio opened this issue 1 year ago • 4 comments
trafficstars

HTTP 404 for url http://metadata.google.internal/computeMetadata/v1/instance/attributes/tpu-env when executing

from torch_xla._internal import tpu
tpu.num_available_devices()

See https://github.com/Lightning-AI/pytorch-lightning/issues/19274

BrandonStudio avatar Feb 20 '24 13:02 BrandonStudio

which version did you use? Colab is still on the old TPU Node architure so the last version we support is pytorch 2.0 with the old XRT runtime. The api you are trying to use belongs to the new PJRT runtime I believe. Can you try to use kaggle? Colab is working on the new TPUVM support and we should see more updates in next few months.

JackCaoG avatar Feb 20 '24 18:02 JackCaoG

I believe I had used Kaggle without problems.

Could you give a guide about how to use tpu on Colab? As Google Colab is a widely-used free TPU platform and there are a bunch of different and contradictory methods. Should I install libtpu instead of torch_xla?

BrandonStudio avatar Feb 21 '24 01:02 BrandonStudio

You can install pytorch 2.0 and torch_xla 2.0 XRT build at

https://storage.googleapis.com/tpu-pytorch/wheels/colab/torch_xla-2.0-cp310-cp310-linux_x86_64.whl

then it should work

JackCaoG avatar Feb 21 '24 21:02 JackCaoG

No, it does not work. image

Installation output: image

BrandonStudio avatar Feb 23 '24 05:02 BrandonStudio