build-from-source.rst 2.87 KB
Newer Older
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
.. meta::
   :description: Build LightGBM with ROCm support from source for AMD GPUs
   :keywords: amd, rocm, finance, financial, fintech, algorithm, gpu, install, setup, env, docker, package, contribute, develop, build, pip, make

*******************************
Build ROCm LightGBM from source
*******************************

Prerequisites
=============

Before proceeding, ensure that you have installed a supported ROCm version,
operating system, and Python environment that are compatible with the ROCm
Finance libraries. Verify that your system includes a supported AMD Instinct
GPU. For guidance, see `ROCm finance installation prerequisites
<https://rocm.docs.amd.com/projects/rocm-finance/en/latest/install/prerequisites.html>`__.

For a consistent and streamlined setup experience, it's recommended to use
a ROCm development environment Docker container. See `Install ROCm Finance
<https://rocm.docs.amd.com/projects/rocm-finance/en/latest/install/install.html>`__
for instructions.

Build from source
=================

1. Clone the `<https://github.com/ROCm/LightGBM>`__ source code from GitHub.

   .. code-block:: shell

      git clone --recurse-submodules https://github.com/ROCm/lightgbm/

2. Create and activate a Python virtual environment.

   .. code-block:: shell

      python -m venv lightgbm_build
      source lightgbm_build/bin/activate

3. Configure the ``build`` directory and CMake -- make sure you're using CMake version
   3.8 or greater.

   .. code-block:: shell

      export CMAKE_PREFIX_PATH=/opt/rocm
      export CMAKE_CXX_COMPILER=hipcc
      cmake -DUSE_ROCM=1 -B build -S . -D CMAKE_PREFIX_PATH=/opt/rocm

4. Build the executable binary.

   .. code-block:: shell

      cd build
      make -j

   You should see the LightGBM executable built and placed just outside the ``build`` directory.

   .. code-block:: shell

      cd ..

5. Build the exectuable binary with unit tests.

   .. code-block:: shell

      export CMAKE_PREFIX_PATH=/opt/rocm
      export CMAKE_CXX_COMPILER=hipcc
      cmake -DUSE_ROCM=1 -DBUILD_CPP_TEST=ON -B build -S . CMAKE_PREFIX_PATH=/opt/rocm
      cd build
      cmake --target testlightgbm -j

   To run the unit tests, use:

   .. code-block:: shell

      cd ..
      ./testlightgbm

6. Build and install the Python module.

   .. code-block:: shell

      export CMAKE_PREFIX_PATH=/opt/rocm
      pip install --upgrade pip
      pip install --upgrade --force-reinstall numpy pandas scikit-learn scipy setuptools matplotlib cloudpickle pytest psutil joblib pyarrow dask cffi
      ./build-python.sh bdist_wheel --rocm
      pip install dist/amd_lightgbm*.whl

7. Verify the installation.

   .. code-block:: shell

      pip show -v amd_lightgbm

   .. dropdown:: Example output

      .. code-block:: shell-session

          Name: amd_lightgbm
          Version: 4.6.0.99
          Summary: ROCm Port of LightGBM Python-package
         ... [output truncated]