python3Packages.torchaudio: 2.10.0 -> 2.11.0

Diff: https://github.com/pytorch/audio/compare/v2.10.0...v2.11.0

Changelog: https://github.com/pytorch/audio/releases/tag/v2.11.0
This commit is contained in:
Gaetan Lepage
2026-03-27 21:57:37 +00:00
parent 94198e64e1
commit 1c51f99cb0
@@ -3,88 +3,142 @@
buildPythonPackage,
fetchFromGitHub,
# nativeBuildInputs
cmake,
pkg-config,
ninja,
# buildInputs
pybind11,
sox,
torch,
llvmPackages,
# build-system
setuptools,
# dependencies
torch,
torchcodec,
# tests
inflect,
parameterized,
pytestCheckHook,
pytorch-lightning,
scipy,
sentencepiece,
unidecode,
# passthru
torchaudio,
cudaSupport ? torch.cudaSupport,
cudaPackages,
rocmSupport ? torch.rocmSupport,
rocmPackages,
}:
buildPythonPackage.override { stdenv = torch.stdenv; } (finalAttrs: {
buildPythonPackage.override { inherit (torch) stdenv; } (finalAttrs: {
pname = "torchaudio";
version = "2.10.0";
version = "2.11.0";
pyproject = true;
src = fetchFromGitHub {
owner = "pytorch";
repo = "audio";
tag = "v${finalAttrs.version}";
hash = "sha256-b1sjHVFXdNFDbdtXWSM2KisSRE/8IbzJI4rvzYQ4UMg=";
hash = "sha256-TncROn9wfn5HOaIvupS2/KD9JCgwfHyfnbZRc+SiqJ0=";
};
patches = [
./0001-setup.py-propagate-cmakeFlags.patch
];
postPatch = lib.optionalString rocmSupport ''
# There is no .info/version-dev, only .info/version
substituteInPlace cmake/LoadHIP.cmake \
--replace-fail "/.info/version-dev" "/.info/version"
'';
env = {
# CTC seems to be missing no matter what. No obvious flag to force its compilation.
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CTC_DECODER = 1;
# CUDA
USE_CUDA = cudaSupport;
TORCH_CUDA_ARCH_LIST = "${lib.concatStringsSep ";" torch.cudaCapabilities}";
BUILD_SOX = 0;
BUILD_KALDI = 0;
BUILD_RNNT = 0;
BUILD_CTC_DECODER = 0;
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUCTC_DECODER = 1;
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUDA = 1;
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_MULTIGPU_CUDA = 1;
# At of 2026-03-27, the default `cudaPackages` version is 12.9.1
# According to Nvidia, it should support GCC versions up to 14.x:
# -> https://docs.nvidia.com/cuda/archive/12.9.1/cuda-installation-guide-linux/index.html#host-compiler-support-policy
# However, PyTorch's *strict* upper bound is 14.0:
# -> https://github.com/pytorch/pytorch/blob/v2.11.0/torch/utils/cpp_extension.py#L75
# Hence, the build fails with:
# RuntimeError: The current installed version of g++ (14.3.0) is greater than the maximum
# required version by CUDA 12.9. Please make sure to use an adequate version of g++
# (>=6.0.0, <14.0).
# Hence, we disable the version check to silence the error:
TORCH_DONT_CHECK_COMPILER_ABI = cudaSupport;
# ROCM
USE_ROCM = rocmSupport;
PYTORCH_ROCM_ARCH = lib.optionalString rocmSupport torch.gpuTargetString;
ROCM_PATH = lib.optionalString rocmSupport torch.rocmtoolkit_joined;
# demucs is not packaged in nixpkgs and is archived anyway
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_MOD_demucs = true;
# fairseq is unmaintained and broken in nixpkgs
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_MOD_fairseq = true;
# Fails even on python>3.10 with:
# RuntimeError: Test is known to fail for Python 3.10, disabling for now
# See: https://github.com/pytorch/audio/pull/2224#issuecomment-1048329450
TORCHAUDIO_TEST_ALLOW_SKIP_IF_ON_PYTHON_310 = true;
};
nativeBuildInputs = [
cmake
pkg-config
ninja
]
++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc ]
++ lib.optionals rocmSupport (
with rocmPackages;
[
clr
rocblas
hipblas
build-system = [
setuptools
];
nativeBuildInputs = lib.optionals cudaSupport [
cudaPackages.cuda_nvcc
];
buildInputs =
lib.optionals cudaSupport [
cudaPackages.cuda_cudart
]
);
++ lib.optionals torch.stdenv.cc.isClang [
llvmPackages.openmp
];
buildInputs = [
pybind11
sox
torch.cxxdev
]
++ lib.optionals torch.stdenv.cc.isClang [ llvmPackages.openmp ];
dependencies = [ torch ];
preConfigure = lib.optionalString rocmSupport ''
export ROCM_PATH=${torch.rocmtoolkit_joined}
export PYTORCH_ROCM_ARCH="${torch.gpuTargetString}"
'';
dontUseCmakeConfigure = true;
doCheck = false; # requires sox backend
dependencies = [
torch
torchcodec
];
pythonImportsCheck = [ "torchaudio" ];
nativeCheckInputs = [
inflect
parameterized
pytestCheckHook
pytorch-lightning
scipy
sentencepiece
unidecode
];
disabledTestPaths = [
# Require internet access
"test/integration_tests"
];
disabledTests = [
# AssertionError: Tensor-likes are not close!
# Mismatched elements: 1070 / 32800 (3.3%)
"test_amplitude_to_DB"
"test_amplitude_to_DB_power"
# Very long to run
"AutogradCPUTest"
];
passthru.gpuCheck = torchaudio.overridePythonAttrs (old: {
requiredSystemFeatures = [ "cuda" ];
env = (old.env or { }) // {
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUCTC_DECODER = 0;
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUDA = 0;
};
});
meta = {
description = "PyTorch audio library";
homepage = "https://pytorch.org/";