torchaudio libtorchaudio.so undefined symbol (fix)

import torchaudio fails with OSError: .../torchaudio/lib/libtorchaudio.so: undefined symbol: _ZNK3c106SymInt..., Could not load this library: ...libtorchaudio.so or libtorch_cuda.so: cannot open shared object file. We reproduced all three; each is a torch/torchaudio mismatch.

1. The three errors

A two-line test that prints what pip thinks is installed and then imports torchaudio:

import importlib.metadata as m
print("torch", m.version("torch"), "| torchaudio", m.version("torchaudio"))
import torchaudio
print("imported torchaudio", torchaudio.__version__)

torch 2.8.0 with torchaudio 2.9.0 (traceback trimmed):

torch 2.8.0+cpu | torchaudio 2.9.0+cpu
Traceback (most recent call last):
  ...
OSError: .../site-packages/torchaudio/lib/libtorchaudio.so: undefined symbol: _ZNK3c106SymInt22maybe_as_int_slow_pathEv

torch 2.9.0 with torchaudio 2.8.0: the same undefined symbol (a different one), then torch wraps it in "Could not load this library":

torch 2.9.0+cpu | torchaudio 2.8.0+cpu
Traceback (most recent call last):
  ...
OSError: .../site-packages/torchaudio/lib/libtorchaudio.so: undefined symbol: _ZNK3c106SymInt6sym_neERKS0_

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  ...
OSError: Could not load this library: .../site-packages/torchaudio/lib/libtorchaudio.so

Same version, different build: torch 2.8.0+cpu with the CUDA torchaudio 2.8.0 wheel from PyPI (built for cu128):

torch 2.8.0+cpu | torchaudio 2.8.0
Traceback (most recent call last):
  ...
OSError: libtorch_cuda.so: cannot open shared object file: No such file or directory

All three have one cause: libtorchaudio.so is compiled against one exact torch build and loads C++ symbols from it. torchaudio 2.9.0 declares torch==2.9.0 and 2.8.0 declares torch==2.8.0, but pip install --no-deps, a second index URL or a conda/pip mix can still leave a mismatched pair. pip check catches the version mismatch:

torchaudio 2.9.0+cpu has requirement torch==2.9.0, but you have torch 2.8.0+cpu.

but not the CPU/CUDA mix: in the third case it printed No broken requirements found., because the PyPI wheel's metadata says plain 2.8.0.

2. See what you have without importing torchaudio

This reads torchaudio's requirement and its built-in version file (which keeps the +cpu/+cu128 tag) and compares them with torch:

# Diagnose without importing torchaudio: versions AND build tags must match
import importlib.metadata as m, importlib.util, pathlib, torch
need = [r for r in (m.requires("torchaudio") or []) if r.startswith("torch")]
print("torchaudio requires:", need)
ta_dir = pathlib.Path(importlib.util.find_spec("torchaudio").origin).parent
print("torchaudio build:", (ta_dir / "version.py").read_text().splitlines()[0])
print("torch build:      ", torch.__version__, "| CUDA:", torch.version.cuda)

CPU/CUDA mix:

torchaudio requires: ['torch==2.8.0']
torchaudio build: __version__ = '2.8.0+cu128'
torch build:       2.8.0+cpu | CUDA: None

Version mismatch (torch 2.9.0, torchaudio 2.8.0):

torchaudio requires: ['torch==2.8.0']
torchaudio build: __version__ = '2.8.0+cpu'
torch build:       2.9.0+cpu | CUDA: None

The two must agree on the version (2.8.0) and the build tag (+cpu, +cu128, ...). If torch says CUDA: None, torchaudio needs a +cpu build.

3. Fix: reinstall torchaudio to match torch

Pick the torchaudio with the same version and build tag as your torch, from the same index, and force it in. For the CPU/CUDA mix above (torch 2.8.0+cpu):

pip install --force-reinstall --no-deps torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cpu

Then b1.py printed:

torch 2.8.0+cpu | torchaudio 2.8.0+cpu
imported torchaudio 2.8.0+cpu

--force-reinstall matters: without it, pip install torch==2.8.0 torchaudio==2.8.0 --index-url .../whl/cpu treated the installed CUDA build as already satisfying ==2.8.0, and the import still failed with libtorch_cuda.so. For a CUDA torch, use its tag in the URL (e.g. /whl/cu128). For a version mismatch, install the torchaudio version that equals torch's; after fixing the torch 2.8.0 / torchaudio 2.9.0 pair, b2.py printed:

torchaudio requires: ['torch==2.8.0']
torchaudio build: __version__ = '2.8.0+cpu'
torch build:       2.8.0+cpu | CUDA: None

The torch 2.9.0 pair imported the same way (imported torchaudio 2.9.0+cpu). If you can't change torch (another package pins it), install the torchaudio that matches it rather than the newest one; if you're on torchaudio 2.9, also see what it removed below.

Related: Could not load libtorchcodec (the same kind of mismatch for TorchCodec) · operator torchvision::nms does not exist (the same mismatch for torchvision) · No module named torchaudio.backend · torchaudio has no attribute info

Frequently asked questions

Why does libtorchaudio.so have an undefined symbol?

It was built against a different torch version than the one installed. torchaudio 2.9.0 needs torch 2.9.0, 2.8.0 needs 2.8.0; any other pair fails at import.

Why libtorch_cuda.so: cannot open shared object file?

torch is a CPU build but torchaudio is a CUDA build of the same version. pip check does not flag it; reinstall torchaudio from the same index as torch (e.g. the /whl/cpu index).

Written with AI assistance. Measured on 2026-10-24 on Linux with CPython 3.11.17, torch 2.8.0/2.9.0 CPU wheels, torchaudio 2.8.0/2.9.0 CPU wheels and the PyPI torchaudio 2.8.0 (cu128) wheel. Output pasted unedited except shortened paths and trimmed tracebacks. PlainTables is our extension; torch and torchaudio are free.