impure-shell.nix 1.79 KB
Newer Older
1
{
2
  lib,
3
  mkShell,
4
  black,
5
  cmake,
6
  isort,
7
8
9
  ninja,
  which,
  cudaPackages,
10
11
12
13
14
15
16
17
18
  openssl,
  pkg-config,
  protobuf,
  python3,
  pyright,
  redocly,
  ruff,
  rust-bin,
  server,
19
20
21
22

  # Enable dependencies for building CUDA packages. Useful for e.g.
  # developing marlin/moe-kernels in-place.
  withCuda ? false,
23
24
25
}:

mkShell {
26
  nativeBuildInputs =
27
    [
28
29
      black
      isort
30
31
32
33
34
35
36
37
38
39
40
41
      pkg-config
      (rust-bin.stable.latest.default.override {
        extensions = [
          "rust-analyzer"
          "rust-src"
        ];
      })
      protobuf
      pyright
      redocly
      ruff
    ]
42
43
44
45
46
47
48
49
50
51
52
53
54
    ++ (lib.optionals withCuda [
      cmake
      ninja
      which

      # For most Torch-based extensions, setting CUDA_HOME is enough, but
      # some custom CMake builds (e.g. vLLM) also need to have nvcc in PATH.
      cudaPackages.cuda_nvcc
    ]);
  buildInputs =
    [
      openssl.dev
    ]
55
56
57
58
59
60
61
62
63
    ++ (with python3.pkgs; [
      venvShellHook
      docker
      pip
      ipdb
      click
      pytest
      pytest-asyncio
      syrupy
64
65
66
67
68
69
    ])
    ++ (lib.optionals withCuda (
      with cudaPackages;
      [
        cuda_cccl
        cuda_cudart
70
        cuda_nvrtc
71
        cuda_nvtx
72
        cuda_profiler_api
73
74
75
76
77
78
        cudnn
        libcublas
        libcusolver
        libcusparse
      ]
    ));
79
80
81

  inputsFrom = [ server ];

82
83
84
85
86
  env = lib.optionalAttrs withCuda {
    CUDA_HOME = "${lib.getDev cudaPackages.cuda_nvcc}";
    TORCH_CUDA_ARCH_LIST = lib.concatStringsSep ";" python3.pkgs.torch.cudaCapabilities;
  };

87
88
89
90
91
92
93
  venvDir = "./.venv";

  postVenvCreation = ''
    unset SOURCE_DATE_EPOCH
    ( cd server ; python -m pip install --no-dependencies -e . )
    ( cd clients/python ; python -m pip install --no-dependencies -e . )
  '';
94

95
96
97
98
99
  postShellHook = ''
    unset SOURCE_DATE_EPOCH
    export PATH=$PATH:~/.cargo/bin
  '';
}