Search code examples
google-cloud-platformpytorchtputorchvision

How do I use torchaudio with torch_xla on google colab TPU?


I was using google colab (GPU enabled) to train my Automatic Speech Recognition Model based on pytorch and torchaudio. But when I tried to use google colab TPU I got the following error when training my model :

ImportError: /usr/local/lib/python3.6/dist-packages/_torch_sox.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe28TypeMeta21_typeMetaDataInstanceISt7complexIfEEEPKNS_6detail12TypeMetaDataEv site:stackoverflow.com

I'm almost sure it's a conflict between torchaudio and pytorch_xla versions

Here's the code that I use to install the librairies :

VERSION = "nightly"  #@param ["1.5" , "20200325", "nightly"]
!curl https://raw.githubusercontent.com/pytorch/xla/master/contrib/scripts/env-setup.py -o pytorch-xla-env-setup.py
!pip install torchvision==0.6.1
!pip install torch==1.5.1
!pip install torchaudio==0.5.1
!python pytorch-xla-env-setup.py --version $VERSION

The solution proposed here https://stackoverflow.com/a/60929133/13847989 generated the following error :

ImportError: /usr/local/lib/python3.6/dist-packages/_torch_sox.cpython-36m-x86_64-linux-gnu.so: undefined symbol: THPVariableClass

What am I doing wrong ?


Solution

  • Can you try installing torchaudio from source after running the setup script (https://github.com/pytorch/audio#from-source)? Sounds like its due to a version mismatch (nightly torch vs stable torchaudio).