Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at python-updates 92 lines 2.4 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 python, 6 fetchurl, 7 pythonOlder, 8 pythonAtLeast, 9 10 # buildInputs 11 cudaPackages, 12 ffmpeg_6, 13 sox, 14 15 # nativeBuildInputs 16 addDriverRunpath, 17 autoPatchelfHook, 18 19 # dependencies 20 torch-bin, 21}: 22 23buildPythonPackage (finalAttrs: { 24 pname = "torchaudio"; 25 version = "2.10.0"; 26 format = "wheel"; 27 28 src = 29 let 30 pyVerNoDot = lib.replaceStrings [ "." ] [ "" ] python.pythonVersion; 31 unsupported = throw "Unsupported system"; 32 srcs = 33 (import ./binary-hashes.nix finalAttrs.version)."${stdenv.system}-${pyVerNoDot}" or unsupported; 34 in 35 fetchurl srcs; 36 37 disabled = (pythonOlder "3.10") || (pythonAtLeast "3.15"); 38 39 buildInputs = [ 40 # We need to patch lib/torio/_torio_ffmpeg6 41 ffmpeg_6.dev 42 sox 43 ] 44 ++ lib.optionals stdenv.hostPlatform.isLinux ( 45 with cudaPackages; 46 [ 47 # $out/${sitePackages}/torchaudio/lib/libtorchaudio*.so wants libcudart.so.11.0 but torch/lib only ships 48 # libcudart.$hash.so.11.0 49 cuda_cudart 50 51 # $out/${sitePackages}/torchaudio/lib/libtorchaudio*.so wants libnvToolsExt.so.2 but torch/lib only ships 52 # libnvToolsExt-$hash.so.1 53 cuda_nvtx 54 ] 55 ); 56 57 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ 58 autoPatchelfHook 59 addDriverRunpath 60 ]; 61 62 dependencies = [ torch-bin ]; 63 64 preInstall = lib.optionals stdenv.hostPlatform.isLinux '' 65 addAutoPatchelfSearchPath "${torch-bin}/${python.sitePackages}/torch" 66 ''; 67 68 # The wheel-binary is not stripped to avoid the error of `ImportError: libtorch_cuda_cpp.so: ELF load command address/offset not properly aligned.`. 69 dontStrip = true; 70 71 pythonImportsCheck = [ "torchaudio" ]; 72 73 meta = { 74 description = "PyTorch audio library"; 75 homepage = "https://pytorch.org/"; 76 changelog = "https://github.com/pytorch/audio/releases/tag/v${finalAttrs.version}"; 77 # Includes CUDA and Intel MKL, but redistributions of the binary are not limited. 78 # https://docs.nvidia.com/cuda/eula/index.html 79 # https://www.intel.com/content/www/us/en/developer/articles/license/onemkl-license-faq.html 80 license = lib.licenses.bsd3; 81 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 82 platforms = [ 83 "aarch64-linux" 84 "x86_64-linux" 85 "aarch64-darwin" 86 ]; 87 maintainers = with lib.maintainers; [ 88 GaetanLepage 89 junjihashimoto 90 ]; 91 }; 92})