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

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

mkShell {
27
  nativeBuildInputs =
28
    [
29
30
      black
      isort
31
      pkg-config
32
      poetry
33
34
35
36
37
38
39
40
41
42
43
      (rust-bin.stable.latest.default.override {
        extensions = [
          "rust-analyzer"
          "rust-src"
        ];
      })
      protobuf
      pyright
      redocly
      ruff
    ]
44
45
46
47
48
49
50
51
52
53
54
55
56
    ++ (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
    ]
57
58
59
60
61
62
63
64
65
    ++ (with python3.pkgs; [
      venvShellHook
      docker
      pip
      ipdb
      click
      pytest
      pytest-asyncio
      syrupy
66
67
68
69
70
71
    ])
    ++ (lib.optionals withCuda (
      with cudaPackages;
      [
        cuda_cccl
        cuda_cudart
72
        cuda_nvrtc
73
        cuda_nvtx
74
        cuda_profiler_api
75
76
77
78
79
80
        cudnn
        libcublas
        libcusolver
        libcusparse
      ]
    ));
81
82
83

  inputsFrom = [ server ];

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

89
90
91
92
93
94
95
  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 . )
  '';
96

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