summary refs log tree commit diff
path: root/pkgs/development/libraries/xgboost/default.nix
blob: 6f296bb40b901c42bd040683340a5a2b74327398 (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
{ stdenv, lib, fetchgit, cmake
, avxSupport ? false
, cudaSupport ? false, cudatoolkit
, ncclSupport ? false, nccl
}:

assert ncclSupport -> cudaSupport;

stdenv.mkDerivation rec {
  name = "xgboost-${version}";
  version = "0.7";

  # needs submodules
  src = fetchgit {
    url = "https://github.com/dmlc/xgboost";
    rev = "refs/tags/v${version}";
    sha256 = "1wxh020l4q037hc5z7vgxflb70l41a97anl8g6y4wxb74l5zv61l";
  };

  enableParallelBuilding = true;

  nativeBuildInputs = [ cmake ];

  buildInputs = lib.optional cudaSupport cudatoolkit
                ++ lib.optional ncclSupport nccl;

  cmakeFlags = lib.optionals cudaSupport [ "-DUSE_CUDA=ON" "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/cc" ]
               ++ lib.optional ncclSupport "-DUSE_NCCL=ON";

  installPhase = ''
    mkdir -p $out
    cp -r ../include $out
    install -Dm755 ../lib/libxgboost.so $out/lib/libxgboost.so
    install -Dm755 ../xgboost $out/bin/xgboost
  '';

  meta = with stdenv.lib; {
    description = "Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library";
    homepage = https://github.com/dmlc/xgboost;
    license = licenses.asl20;
    platforms = platforms.linux;
    maintainers = with maintainers; [ abbradar ];
  };
}