I am having the exact same issue on an Ubuntu image created with Docker.
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION=“Ubuntu 20.04.5 LTS”
python3 test_cuda.py
/usr/local/lib/python3.8/dist-packages/torchaudio/_internal/module_utils.py:99: UserWarning: Failed to import soundfile. ‘soundfile’ backend is not available.
warnings.warn(“Failed to import soundfile. ‘soundfile’ backend is not available.”)
PyTorch version: 1.11.0+cu113
PyTorch can use GPU: True
Torch CUDA version: 11.3
Torchaudio version: 0.11.0+cu113
Torchaudio backend: sox_io
Trochaudio backends list: [‘soundfile’, ‘sox_io’]
Torchvision version: 0.12.0+cu113
Torchvision video backend: pyav
Torch CUDA available: True
CUDA device count: 1
Current CUDA device: 0
Device name: NVIDIA GeForce RTX 4090
pip list | grep -i sound
SoundFile 0.10.2
pip list | grep librosa
librosa 0.9.2
apt list | grep libsnd
libsndfile1-dev/focal-updates,focal-security 1.0.28-7ubuntu0.1 amd64
libsndfile1/focal-updates,focal-security 1.0.28-7ubuntu0.1 amd64
libsndifsdl2-dev/focal 0.8.3-2 amd64
libsndio-dev/focal 1.5.0-3 amd64
libsndio7.0/focal 1.5.0-3 amd64
libsndobj-dev/focal 2.6.7+ds1-3 amd64
libsndobj2v5/focal 2.6.7+ds1-3 amd64
I am also running apt update at the very top of my Dockerfile. I also started the container and just to be sure ran apt update and apt-get update and same problem.
python3 -c “import soundfile”
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python3.8/dist-packages/soundfile.py”, line 142, in
raise OSError(‘sndfile library not found’)
OSError: sndfile library not found
Now from the reading I have done online, Linux uses sox and not soundfile so why is torchaudio trying to access this in the first place?