Using torchaudio on google tpu, load pytorch xla using pytorch 1.4.0

username: Laurence_J
cooked: <p>I’m trying to run a pytorch script which is using torchaudio on a google TPU. To do this I’m using <a href="https://github.com/pytorch/xla" rel="nofollow noopener">pytorch xla</a> following <a href="https://colab.research.google.com/github/pytorch/xla/blob/master/contrib/colab/style_transfer_inference-xrt-1-15.ipynb#scrollTo=j1w1G4AcWw9f" rel="nofollow noopener">this notebook</a>, more specifically I’m using this code cell to load the xla:</p>
<pre><code class="lang-auto">!pip install torchaudio
import os
assert os.environ['COLAB_TPU_ADDR'], 'Make sure to select TPU from Edit &gt; Notebook settings &gt; Hardware accelerator'

VERSION = "20200220"  #@param ["20200220","nightly", "xrt==1.15.0"]
!curl https://raw.githubusercontent.com/pytorch/xla/master/contrib/scripts/env-setup.py -o pytorch-xla-env-setup.py
!python pytorch-xla-env-setup.py --version $VERSION

import torch

import torchaudio

import torch_xla
</code></pre>
<p>however this is incompatible with the version of torchaudio that I need as: <code>ERROR: torchaudio 0.4.0 has requirement torch==1.4.0, but you'll have torch 1.5.0a0+e95282a which is incompatible.</code></p>
<p>I couldn’t find anywhere how to load <code>torch 1.4.0</code> using pytorch xla.</p>
<p>I tried to use the nightly version of torch audio but that gives the error as follows:</p>
<pre><code class="lang-auto">!pip install torchaudio_nightly -f https://download.pytorch.org/whl/nightly/torch_nightly.html

import os
assert os.environ['COLAB_TPU_ADDR'], 'Make sure to select TPU from Edit &gt; Notebook settings &gt; Hardware accelerator'

VERSION = "20200220"  #@param ["20200220","nightly", "xrt==1.15.0"]
!curl https://raw.githubusercontent.com/pytorch/xla/master/contrib/scripts/env-setup.py -o pytorch-xla-env-setup.py
!python pytorch-xla-env-setup.py --version $VERSION

import torch
import torchaudio

import torch_xla
</code></pre>
<pre><code class="lang-auto">---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
&lt;ipython-input-2-968e9d93c06f&gt; in &lt;module&gt;()
      9 
     10 import torch
---&gt; 11 import torchaudio
     12 
     13 import torch_xla

/usr/local/lib/python3.6/dist-packages/torchaudio/__init__.py in &lt;module&gt;()
      3 
      4 import torch
----&gt; 5 import _torch_sox
      6 
      7 from .version import __version__, git_version

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

---------------------------------------------------------------------------
</code></pre>
<p>So how would I go to load the stable version or 1.4.0 version of pytorch using xla or is there any other workaround for this situation?</p>
<p>Thanks a lot for your help!</p>

username: Ali_Hariri
cooked: <p><a class="mention" href="/u/laurence_j">@Laurence_J</a> Were you able to solve this problem ?</p>

username: Laurence_J
cooked: <p>Hey <a class="mention" href="/u/ali_hariri">@Ali_Hariri</a>, this worked <a href="https://stackoverflow.com/questions/60718831/how-to-use-torchaudio-with-torch-xla-on-google-colab-tpu" rel="nofollow noopener">https://stackoverflow.com/questions/60718831/how-to-use-torchaudio-with-torch-xla-on-google-colab-tpu</a></p>