Installing torchaudio on google colab

Hi,

I am trying to install the torchaudio library in google Colaboratory notebook. However I get this dependency error:

running install
running bdist_egg
running egg_info
creating torchaudio.egg-info
writing torchaudio.egg-info/PKG-INFO
writing dependency_links to torchaudio.egg-info/dependency_links.txt
writing top-level names to torchaudio.egg-info/top_level.txt
writing manifest file 'torchaudio.egg-info/SOURCES.txt'
reading manifest file 'torchaudio.egg-info/SOURCES.txt'
writing manifest file 'torchaudio.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_ext
building '_torch_sox' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/torchaudio
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-sXpGnM/python3.6-3.6.3=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/lib/python3.6/dist-packages/torch/lib/include -I/usr/local/lib/python3.6/dist-packages/torch/lib/include/TH -I/usr/local/lib/python3.6/dist-packages/torch/lib/include/THC -I/usr/include/python3.6m -c torchaudio/torch_sox.cpp -o build/temp.linux-x86_64-3.6/torchaudio/torch_sox.o -DTORCH_EXTENSION_NAME=_torch_sox -std=c++11
x86_64-linux-gnu-gcc: error: torchaudio/torch_sox.cpp: No such file or directory
x86_64-linux-gnu-gcc: fatal error: no input files
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Is there any workaround to fix this issue ?

Best Regards

I just installed it via pip on Google Colab directly from the GitHub repo and it works fine.

pip install git+git://github.com/pytorch/audio

Note that you need to install the required dependencies via apt-get first as mentioned in the GitHub repo. Also you need to have PyTorch installed, otherwise you will get an error during the install.

EDIT:

The dependencies I mentioned above are the ones listed for Ubuntu Linux (https://github.com/pytorch/audio#dependencies). Worked fine for me in the Colaboratory Notebook:

apt-get install sox libsox-dev libsox-fmt-all
2 Likes

Actually I was installing it manually and found that I should have installed ‘cffi’ first as additional dependency. However the direct installation via pip you have provided is awesome. Thaanks

Tried the following:

!sudo apt-get install sox libsox-dev libsox-fmt-all
!pip install git+git://github.com/pytorch/audio

Got the following message:
Successfully built torchaudio

However, got the following error while importing torchaudio:
import torchaudio
RuntimeError: Failed to parse the argument list of a type annotation: name 'Optional' is not defined

Am I missing something?

This worked finally:

!git clone https://github.com/pytorch/audio.git
os.chdir("audio")
!git checkout 301e2e9
!python setup.py install

Source : https://github.com/pytorch/audio/issues/71