v0.12.0:4 - hotfix: torchaudio build fails without --no-build-isolation

Build was crashing inside torchaudio's setup.py with:
  ModuleNotFoundError: No module named 'torch'

PIP_CONSTRAINT was correctly pinning torch/torchvision in the install
target env, but pip's PEP 517 build isolation creates a SEPARATE fresh
Python env just for the build wheel step — and that env has no torch
in it. torchaudio's setup.py imports torch to discover CUDA flags, so
it crashes. Pip even printed a deprecation warning that this isolation
behavior is hardening, not relaxing.

Fix:
  1. Pre-install torchaudio's build deps (setuptools, wheel, ninja,
     pybind11) into the main env since we're disabling isolation.
  2. Add --no-build-isolation to the torchaudio install so the build
     uses NGC's torch directly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Keysat
2026-05-18 21:53:43 -05:00
parent 09a1d3590d
commit a24610ad2a
2 changed files with 18 additions and 5 deletions
+16 -3
View File
@@ -43,11 +43,24 @@ sys.stdout.write(f'torch=={torch.__version__}\ntorchvision=={torchvision.__versi
# NGC PyTorch images don't include torchaudio (NVIDIA optimizes for
# vision/text workloads). Stock torchaudio wheels are ABI-incompatible with
# NGC's custom torch 2.10a, so the only working option is building from
# source against the NGC torch already in the image. Pinning to v2.5.1 — the
# last torchaudio tag that builds cleanly against torch 2.52.10 and is a
# proven compatibility target.
# source against the NGC torch already in the image.
#
# Build env knobs:
# USE_CUDA=1 — build CUDA kernels (we have a GPU)
# BUILD_SOX=0 — skip libsox (we only use audio decoding)
# TORCH_CUDA_ARCH_LIST=... — build kernels for Hopper + Blackwell datacenter
# + Blackwell consumer (sm_120 = GB10)
# --no-build-isolation — CRITICAL: PEP 517 build isolation creates a
# fresh env with no torch in it. torchaudio's
# setup.py imports torch to discover the build
# flags, so it crashes without this flag.
# With it, the build uses NGC's torch directly.
ENV USE_CUDA=1 BUILD_SOX=0 TORCH_CUDA_ARCH_LIST="9.0;10.0;12.0"
# Pre-install torchaudio's build-time deps (PEP 517 would normally install
# these in the isolated build env, but we just turned isolation off).
RUN pip install --break-system-packages --no-cache-dir \
"setuptools>=61" wheel ninja "pybind11>=2.10"
RUN pip install --break-system-packages --no-cache-dir --no-build-isolation \
git+https://github.com/pytorch/audio.git@v2.5.1 \
&& python3 -c "import torchaudio; print('torchaudio built:', torchaudio.__version__)"