flake.nix 2.9 KB
Newer Older
1
2
{
  inputs = {
3
4
5
6
    crate2nix = {
      url = "github:nix-community/crate2nix";
      inputs.nixpkgs.follows = "tgi-nix/nixpkgs";
    };
7
8
9
    tgi-nix.url = "github:danieldk/tgi-nix";
    nixpkgs.follows = "tgi-nix/nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
Nicolas Patry's avatar
Nicolas Patry committed
10
    poetry2nix.url = "github:nix-community/poetry2nix";
11
12
13
14
    rust-overlay = {
      url = "github:oxalica/rust-overlay";
      inputs.nixpkgs.follows = "tgi-nix/nixpkgs";
    };
15
16
17
18
  };
  outputs =
    {
      self,
19
      crate2nix,
20
21
      nixpkgs,
      flake-utils,
22
      rust-overlay,
23
      tgi-nix,
Nicolas Patry's avatar
Nicolas Patry committed
24
      poetry2nix,
25
26
27
28
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
29
30
31
32
        cargoNix = crate2nix.tools.${system}.appliedCargoNix {
          name = "tgi";
          src = ./.;
        };
33
34
35
36
37
38
        config = {
          allowUnfree = true;
          cudaSupport = true;
        };
        pkgs = import nixpkgs {
          inherit config system;
39
40
41
42
          overlays = [
            rust-overlay.overlays.default
            tgi-nix.overlay
          ];
43
        };
Nicolas Patry's avatar
Nicolas Patry committed
44
45
46
47
48

        inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryEditablePackage;
        text-generation-server = mkPoetryEditablePackage {
            editablePackageSources = ./server;
        };
49
50
51
52
53
54
55
56
57
      in
      {
        devShells.default =
          with pkgs;
          mkShell {
            buildInputs =
              [
                openssl.dev
                pkg-config
58
59
60
61
62
63
                (rust-bin.stable.latest.default.override {
                  extensions = [
                    "rust-analyzer"
                    "rust-src"
                  ];
                })
64
65
66
67
68
              ]
              ++ (with python3.pkgs; [
                venvShellHook
                pip

69
                causal-conv1d
Nicolas Patry's avatar
Nicolas Patry committed
70
                click
71
72
                einops
                fbgemm-gpu
Nicolas Patry's avatar
Nicolas Patry committed
73
                flashinfer
74
75
76
77
78
79
                flash-attn
                flash-attn-layer-norm
                flash-attn-rotary
                grpc-interceptor
                grpcio-reflection
                grpcio-status
Nicolas Patry's avatar
Nicolas Patry committed
80
                grpcio-tools
81
82
                hf-transfer
                loguru
83
                mamba-ssm
84
85
86
87
88
89
90
91
92
93
                marlin-kernels
                opentelemetry-api
                opentelemetry-exporter-otlp
                opentelemetry-instrumentation-grpc
                opentelemetry-semantic-conventions
                peft
                tokenizers
                torch
                transformers
                vllm
94

95
96
                cargoNix.workspaceMembers.text-generation-launcher.build 

97
98
99
                (callPackage ./router.nix {
                  inherit (rustPlatform) buildRustPackage importCargoLock;
                })
100
101
102
103
104
105
106
107
108
109
110
111
112
113
              ]);

            venvDir = "./.venv";

            postVenv = ''
              unset SOURCE_DATE_EPOCH
            '';
            postShellHook = ''
              unset SOURCE_DATE_EPOCH
            '';
          };
      }
    );
}