torchaudio.utils has no attribute 'download_asset' (fix)

On torchaudio 2.9, tutorial code fails with ImportError: cannot import name 'download_asset' from 'torchaudio.utils' or AttributeError: module 'torchaudio.utils' has no attribute 'download_asset'. We reproduced both and tested three fixes.

1. The error on torchaudio 2.9

The helper every torchaudio tutorial starts with:

import torchaudio
from torchaudio.utils import download_asset
path = download_asset("tutorial-assets/Lab41-SRI-VOiCES-src-sp0307-ch127535-sg0042.wav", progress=False)
print(torchaudio.__version__, path.split("/hub/")[-1])

torchaudio 2.9.0:

Traceback (most recent call last):
  File "b1.py", line 2, in <module>
    from torchaudio.utils import download_asset
ImportError: cannot import name 'download_asset' from 'torchaudio.utils' (.../site-packages/torchaudio/utils/__init__.py)

Called as an attribute it's an AttributeError instead, and Python points at the private name that is left:

import torchaudio
print(torchaudio.__version__)
path = torchaudio.utils.download_asset("tutorial-assets/steam-train-whistle-daniel_simon.wav")
2.9.0+cpu
Traceback (most recent call last):
  File "b3.py", line 3, in <module>
    path = torchaudio.utils.download_asset("tutorial-assets/steam-train-whistle-daniel_simon.wav")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'torchaudio.utils' has no attribute 'download_asset'. Did you mean: '_download_asset'?

On torchaudio 2.8.0 the same b1.py downloads the file and warns (line shortened):

b1.py:3: UserWarning: torchaudio.utils.download.download_asset has been deprecated. This deprecation is part of a large refactoring effort to transition Torc...
  path = download_asset("tutorial-assets/Lab41-SRI-VOiCES-src-sp0307-ch127535-sg0042.wav", progress=False)
2.8.0+cu128 torchaudio/tutorial-assets/Lab41-SRI-VOiCES-src-sp0307-ch127535-sg0042.wav

The full warning ends "It will be removed from the 2.9 release." In 2.9 torchaudio.utils only exports _download_asset.

2. Fix: a 6-line replacement

download_asset(key) only fetched https://download.pytorch.org/torchaudio/{key} into the torch hub directory. Doing that yourself works on any version:

import os, torch
def download_asset(key):
    # what torchaudio.utils.download_asset did before 2.9
    path = os.path.join(torch.hub.get_dir(), "torchaudio", key)
    if not os.path.exists(path):
        os.makedirs(os.path.dirname(path), exist_ok=True)
        torch.hub.download_url_to_file(f"https://download.pytorch.org/torchaudio/{key}", path, progress=False)
    return path
path = download_asset("tutorial-assets/Lab41-SRI-VOiCES-src-sp0307-ch127535-sg0042.wav")
import soundfile as sf
data, sr = sf.read(path)
print(torch.__version__, data.shape, sr)

torchaudio 2.9.0 (the 2.8.0 run printed the same shape and rate):

2.9.0+cpu (54400,) 16000

The file it saved had the same SHA-256 as the one 2.8's download_asset saved. We read it with soundfile because torchaudio.load on 2.9 needs TorchCodec and FFmpeg (see this if that fails).

3. Quick fix: _download_asset

For a notebook you just want to run, the private function still exists on 2.9.0:

import torchaudio
from torchaudio.utils import _download_asset
path = _download_asset("tutorial-assets/Lab41-SRI-VOiCES-src-sp0307-ch127535-sg0042.wav", progress=False)
print(torchaudio.__version__, path.split("/hub/")[-1])
2.9.0+cpu torchaudio/tutorial-assets/Lab41-SRI-VOiCES-src-sp0307-ch127535-sg0042.wav

It is underscore-prefixed, so it can change or disappear in any release; use the replacement above in code you keep. Pinning torch==2.8.0 torchaudio==2.8.0 also works, with the deprecation warning.

Related: No module named torchaudio.backend · No module named torchaudio.io · torchaudio sox_effects: libsox.so not found · CTC Decoder suit requires flashlight-text

Frequently asked questions

Which torchaudio version removed download_asset?

torchaudio 2.9.0. On 2.8.0 it works and warns that it will be removed from the 2.9 release.

What URL did download_asset use?

https://download.pytorch.org/torchaudio/ followed by the key, saved under torch.hub.get_dir()/torchaudio/. The replacement on this page does the same.

Written with AI assistance. Measured on 2026-10-24 on Linux with CPython 3.11.17, torch/torchaudio 2.8.0 (PyPI wheels) and 2.9.0 (CPU wheels), soundfile. Output pasted unedited except shortened site-packages paths and a trimmed warning line. PlainTables is our extension; torchaudio is free.