nixpkgs/pkgs/development/libraries/xgboost/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
2.1 KiB
Nix
Raw Normal View History

2021-05-08 19:17:56 +00:00
{ config
, stdenv
, lib
, fetchFromGitHub
, cmake
, gtest
, doCheck ? true
, cudaSupport ? config.cudaSupport or false
, ncclSupport ? false
, cudaPackages
, llvmPackages
}:
assert ncclSupport -> cudaSupport;
2016-05-13 23:03:54 +00:00
stdenv.mkDerivation rec {
pname = "xgboost";
2023-01-09 07:06:33 +00:00
version = "1.7.3";
2021-05-08 19:17:56 +00:00
src = fetchFromGitHub {
owner = "dmlc";
repo = pname;
rev = "v${version}";
fetchSubmodules = true;
2023-01-09 07:06:33 +00:00
hash = "sha256-unTss2byytG8KUQfg5s34YpRuHHDLo7D/ZickHhz1AE=";
2016-05-13 23:03:54 +00:00
};
2022-05-12 09:59:53 +00:00
nativeBuildInputs = [
cmake
] ++ lib.optionals stdenv.isDarwin [
llvmPackages.openmp
] ++ lib.optionals cudaSupport [
cudaPackages.autoAddOpenGLRunpathHook
];
buildInputs = [ gtest ] ++ lib.optional cudaSupport cudaPackages.cudatoolkit
++ lib.optional ncclSupport cudaPackages.nccl;
2021-05-08 19:17:56 +00:00
cmakeFlags = lib.optionals doCheck [ "-DGOOGLE_TEST=ON" ]
++ lib.optionals cudaSupport [ "-DUSE_CUDA=ON" "-DCUDA_HOST_COMPILER=${cudaPackages.cudatoolkit.cc}/bin/cc" ]
++ lib.optionals (cudaSupport && lib.versionAtLeast cudaPackages.cudatoolkit.version "11.4.0") [ "-DBUILD_WITH_CUDA_CUB=ON" ]
2021-05-08 19:17:56 +00:00
++ lib.optionals ncclSupport [ "-DUSE_NCCL=ON" ];
inherit doCheck;
# By default, cmake build will run ctests with all checks enabled
# If we're building with cuda, we run ctest manually so that we can skip the GPU tests
checkPhase = lib.optionalString cudaSupport ''
ctest --force-new-ctest-process ${lib.optionalString cudaSupport "-E TestXGBoostLib"}
'';
installPhase = let
libname = "libxgboost${stdenv.hostPlatform.extensions.sharedLibrary}";
in ''
2021-05-08 19:17:56 +00:00
runHook preInstall
2016-05-13 23:03:54 +00:00
mkdir -p $out
cp -r ../include $out
cp -r ../dmlc-core/include/dmlc $out/include
cp -r ../rabit/include/rabit $out/include
install -Dm755 ../lib/${libname} $out/lib/${libname}
install -Dm755 ../xgboost $out/bin/xgboost
2021-05-08 19:17:56 +00:00
runHook postInstall
2016-05-13 23:03:54 +00:00
'';
meta = with lib; {
2016-05-13 23:03:54 +00:00
description = "Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library";
homepage = "https://github.com/dmlc/xgboost";
license = licenses.asl20;
2021-05-08 19:17:56 +00:00
platforms = platforms.unix;
maintainers = with maintainers; [ abbradar nviets ];
2016-05-13 23:03:54 +00:00
};
}