pytorchtpu

PyTorch XLA incompatibility issue when running a modified official example


When running this sample using PyTorch XLA modified slightly from the official sample in Colab, the following errors are presented:

ImportError: /usr/local/lib/python3.7/dist-packages/_XLAC.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN2at13_foreach_erf_EN3c108ArrayRefINS_6TensorEEE.

This seems to be from the code snippet import torch_xla, which seems to point to an incompatibility error. However, I am not able to locate the error.


Solution

  • This error happens because your torch_xla and torch are not the same versions, as I see in the sample you shared you use torch_xla version 1.9.

    Check your torch version; torch.__version__ if it is not '1.9.0+cu111'

    Use;

    !pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
    

    Then

    !pip install cloud-tpu-client==0.10 https://storage.googleapis.com/tpu-pytorch/wheels/torch_xla-1.9-cp37-cp37m-linux_x86_64.whl 
    

    This should solve your issue.