I want to run PyTorch code on Linux. I start a virtual machine on AWS with AMI Deep Learning PyTorch
, but, surprisingly, PyTorch is not installed. So I run:
python3 -m pip install torch torchaudio
When I load a WAV file, I get this error:
RuntimeError: Couldn't find appropriate backend to handle uri /path/to/file.wav and format None.
Reading this thread, I install sox:
python3 -m pip install sox
but I get the same error. Reading this thread, I test this code:
import torchaudio
print(torchaudio.utils.sox_utils.list_read_formats())
and I get this error:
Traceback (most recent call last):
File "/opt/conda/lib/python3.10/site-packages/torchaudio/_extension/utils.py", line 207, in wrapped
_init_sox()
File "/opt/conda/lib/python3.10/site-packages/torchaudio/_extension/utils.py", line 70, in _init_sox
_load_lib("libtorchaudio_sox")
File "/opt/conda/lib/python3.10/site-packages/torchaudio/_extension/utils.py", line 64, in _load_lib
torch.ops.load_library(path)
File "/opt/conda/lib/python3.10/site-packages/torch/_ops.py", line 852, in load_library
ctypes.CDLL(path)
File "/opt/conda/lib/python3.10/ctypes/__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libsox.so: cannot open shared object file: No such file or directory
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/conda/lib/python3.10/site-packages/torchaudio/_extension/utils.py", line 209, in wrapped
raise RuntimeError(
RuntimeError: list_read_formats requires sox extension which is not available. Please refer to the stacktrace above for how to resolve this.
so I install sox
with:
sudo apt-get install -y sox
and I confirm that it works:
$ which sox
/usr/bin/sox
I restart the Python3 REPL, and the virtual machine too, and I get the same errors.
How can I install sox for use with PyTorch audio?
libsox.so
withfind / -type f -name libsox.so
, nor withfind / -type f -name libsox.so.3
. And yetsox
is installed with versionSoX v14.4.2
.