summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/xgboost/package.py
blob: 85e9c26de07e8c23be107535c19d2d98b645a76e (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
45
46
47
48
49
50
51
52
53
54
55
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack import *


class Xgboost(CMakePackage, CudaPackage):
    """XGBoost is an optimized distributed gradient boosting library designed to be
    highly efficient, flexible and portable. It implements machine learning algorithms
    under the Gradient Boosting framework. XGBoost provides a parallel tree boosting
    (also known as GBDT, GBM) that solve many data science problems in a fast and
    accurate way. The same code runs on major distributed environment (Hadoop, SGE, MPI)
    and can solve problems beyond billions of examples."""

    homepage = "https://xgboost.ai/"
    git      = "https://github.com/dmlc/xgboost.git"

    maintainers = ['adamjstewart']

    version('master', branch='master', submodules=True)
    version('1.3.3', tag='v1.3.3', submodules=True)
    version('0.90', tag='v0.90', submodules=True, deprecated=True)
    version('0.81', tag='v0.81', submodules=True, deprecated=True)

    variant('nccl', default=False, description='Build with NCCL to enable distributed GPU support')
    variant('openmp', default=True, description='Build with OpenMP support')

    depends_on('cmake@3.13:', type='build')
    depends_on('cmake@3.16:', when='platform=darwin', type='build')
    depends_on('ninja', type='build')
    depends_on('cuda@10:', when='+cuda')
    depends_on('nccl', when='+nccl')
    depends_on('llvm-openmp', when='%apple-clang +openmp')

    conflicts('%gcc@:4', msg='GCC version must be at least 5.0!')
    conflicts('+nccl', when='~cuda', msg='NCCL requires CUDA')
    conflicts('+cuda', when='~openmp', msg='CUDA requires OpenMP')

    generator = 'Ninja'

    def cmake_args(self):
        # https://xgboost.readthedocs.io/en/latest/build.html
        args = [
            self.define_from_variant('USE_CUDA', 'cuda'),
            self.define_from_variant('USE_NCCL', 'nccl'),
            self.define_from_variant('USE_OPENMP', 'openmp'),
        ]

        if '+cuda' in self.spec and 'cuda_arch=none' not in self.spec:
            args.append(self.define(
                'GPU_COMPUTE_VER', self.spec.variants['cuda_arch'].value))

        return args