No module named 'torchaudio.backend.common'

I am trying to use pytorch-nightly with a project on my macOS. pytorch stable can be used, but the results could be better. So, I wanted to give pytorch-nightly a try. If I run the same script using pytorch-nightly, I get the error:

ModuleNotFoundError: No module named 'torchaudio.backend.common'

Is this module for some reason not part of pytorch-nightly?

I tried to install via conda using

mamba create -n pytorch-nightly pytorch-nightly::pytorch pytorch-nightly::torchvision pytorch-nightly::torchaudio -c pytorch-nightly


mamba create -n pytorch-nightly pytorch-nightly::pytorch torchvision torchaudio -c pytorch-nightly

And I also tried via pip

pip3 install --pre torch torchvision torchaudio --index-url

Of course, I used a fresh environment everytime. I just executed import torchaudio.backend.common in the interactive python console. With every pytorch-nightly env I get the ModuleNotFoundError. Doing the same with just pytorch works.

Any ideas?

This PR moved some modules around to _backend.
However, torchaudio.backend.common still works for me in 2.1.0.dev20230817+cu121, which should already contain the linked PR:

<module 'torchaudio.backend._common' from '/home/pbialecki/miniforge3/envs/nightly_pip_cu121/lib/python3.10/site-packages/torchaudio/backend/'>


Hmm, that’s weird.
I get (almost) the same output as you:

>>> torchaudio.backend.common
<module 'torchaudio.backend._common' from '/Users/gernophil/miniconda3/envs/pytorch-nightly/lib/python3.11/site-packages/torchaudio/backend/'>
>>> torchaudio.__version__

Still I cannot run this import command:

from torchaudio.backend.common import AudioMetaData

It’s used by a pyannote fork I use and is does work with the non-nightly version.

However, by importing tfrom torchaudio.backend._common import AudioMetaData I got the message that it’s been moved to torchaudio.AudioMetaData. Should be doable now :).

Try to replace the backend module with _backend as described in the PR and see if this would work.

This is a regression. I intended to keep the existing import compatible. I will fix it.

For the future, if the backward compatibility is not an issue, please use torchaudio.AudioMetaData. (no backend or _backend)

1 Like