summary refs log tree commit diff
path: root/pkgs/development/python-modules/torchaudio/default.nix
blob: 0b38925e0a2b9011276a0d528d94f6e3bd18cac8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{ lib
, buildPythonPackage
, fetchFromGitHub
, cmake
, pkg-config
, ninja
, pybind11
, torch
, cudaSupport ? torch.cudaSupport
, cudaPackages
}:

buildPythonPackage rec {
  pname = "torchaudio";
  version = "2.0.2";

  src = fetchFromGitHub {
    owner = "pytorch";
    repo = "audio";
    rev = "v${version}";
    hash = "sha256-9lB4gLXq0nXHT1+DNOlbJQqNndt2I6kVoNwhMO/2qlE=";
  };

  postPatch = ''
    substituteInPlace setup.py \
      --replace 'print(" --- Initializing submodules")' "return" \
      --replace "_fetch_archives(_parse_sources())" "pass"
  '';

  env = {
    TORCH_CUDA_ARCH_LIST = "${lib.concatStringsSep ";" torch.cudaCapabilities}";
  };

  nativeBuildInputs = [
    cmake
    pkg-config
    ninja
  ] ++ lib.optionals cudaSupport [
    cudaPackages.cuda_nvcc
  ];
  buildInputs = [
    pybind11
  ] ++ lib.optionals cudaSupport [
    cudaPackages.libcurand.dev
    cudaPackages.libcurand.lib
    cudaPackages.cuda_cudart # cuda_runtime.h and libraries
    cudaPackages.cuda_cccl.dev # <thrust/*>
    cudaPackages.cuda_nvtx.dev
    cudaPackages.cuda_nvtx.lib # -llibNVToolsExt
    cudaPackages.libcublas.dev
    cudaPackages.libcublas.lib
    cudaPackages.libcufft.dev
    cudaPackages.libcufft.lib
  ];
  propagatedBuildInputs = [
    torch
  ];

  BUILD_SOX=0;
  BUILD_KALDI=0;
  BUILD_RNNT=0;
  BUILD_CTC_DECODER=0;

  dontUseCmakeConfigure = true;

  doCheck = false; # requires sox backend

  meta = with lib; {
    description = "PyTorch audio library";
    homepage = "https://pytorch.org/";
    changelog = "https://github.com/pytorch/audio/releases/tag/v${version}";
    license = licenses.bsd2;
    platforms = platforms.unix;
    maintainers = with maintainers; [ junjihashimoto ];
  };
}