Installation-Guide.rst 12.1 KB
Newer Older
1
2
3
Installation Guide
==================

4
Here is the guide for the build of LightGBM CLI version.
5
6
7
8
9
10

For the build of Python-package and R-package, please refer to `Python-package`_ and `R-package`_ folders respectively.

Windows
~~~~~~~

11
12
13
14
15
16
17
On Windows LightGBM can be built using

- **Visual Studio**;

- **CMake** and **MSBuild**;

- **CMake** and **MinGW**.
18
19
20
21
22
23
24

Visual Studio (or MSBuild)
^^^^^^^^^^^^^^^^^^^^^^^^^^

With GUI
********

25
1. Install `Visual Studio`_ (2015 or newer).
26
27
28
29
30

2. Download `zip archive`_ and unzip it.

3. Go to ``LightGBM-master/windows`` folder.

31
4. Open ``LightGBM.sln`` file with **Visual Studio**, choose ``Release`` configuration and click ``BUILD`` -> ``Build Solution (Ctrl+Shift+B)``.
32

33
   If you have errors about **Platform Toolset**, go to ``PROJECT`` -> ``Properties`` -> ``Configuration Properties`` -> ``General`` and select the toolset installed on your machine.
34
35
36
37
38
39

The exe file will be in ``LightGBM-master/windows/x64/Release`` folder.

From Command Line
*****************

40
1. Install `Git for Windows`_, `CMake`_ (3.8 or higher) and `MSBuild`_ (**MSBuild** is not needed if **Visual Studio** (2015 or newer) is already installed).
41
42
43
44
45
46
47
48
49
50
51
52
53
54

2. Run the following commands:

   .. code::

     git clone --recursive https://github.com/Microsoft/LightGBM
     cd LightGBM
     mkdir build
     cd build
     cmake -DCMAKE_GENERATOR_PLATFORM=x64 ..
     cmake --build . --target ALL_BUILD --config Release

The exe and dll files will be in ``LightGBM/Release`` folder.

55
56
MinGW-w64
^^^^^^^^^
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

1. Install `Git for Windows`_, `CMake`_ and `MinGW-w64`_.

2. Run the following commands:

   .. code::

     git clone --recursive https://github.com/Microsoft/LightGBM
     cd LightGBM
     mkdir build
     cd build
     cmake -G "MinGW Makefiles" ..
     mingw32-make.exe -j4

The exe and dll files will be in ``LightGBM/`` folder.

73
**Note**: You may need to run the ``cmake -G "MinGW Makefiles" ..`` one more time if met ``sh.exe was found in your PATH`` error.
74

75
76
77
It is recommended to use **Visual Studio** for its better multithreading efficiency in **Windows** for many-core systems (see `FAQ <./FAQ.rst#lightgbm>`__ Question 4 and Question 8).

Also, you may want to read `gcc Tips <./gcc-Tips.rst>`__.
78

79
80
81
Linux
~~~~~

82
On Linux LightGBM can be built using **CMake** and **gcc** or **Clang**.
83

84
1. Install `CMake`_.
85

86
87
88
89
90
91
92
93
2. Run the following commands:

   .. code::

     git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
     mkdir build ; cd build
     cmake ..
     make -j4
94
95
96

**Note**: glibc >= 2.14 is required.

97
Also, you may want to read `gcc Tips <./gcc-Tips.rst>`__.
98

99
100
macOS
~~~~~
101

102
103
104
105
On macOS LightGBM can be built using **CMake** and **Apple Clang** or **gcc**.

Apple Clang
^^^^^^^^^^^
fanliwen's avatar
fanliwen committed
106

107
Only **Apple Clang** version 8.1 or higher is supported.
fanliwen's avatar
fanliwen committed
108

Nikita Titov's avatar
Nikita Titov committed
109
110
1. Install `CMake`_ (3.12 or higher):

111
   .. code::
Nikita Titov's avatar
Nikita Titov committed
112

113
     brew install cmake
fanliwen's avatar
fanliwen committed
114

115
2. Install **OpenMP**:
fanliwen's avatar
fanliwen committed
116
117
118
119

   .. code::

     brew install libomp
120
121
122
123
124

3. Run the following commands:

   .. code::

fanliwen's avatar
fanliwen committed
125
126
127
128
129
     git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
     mkdir build ; cd build
     cmake ..
     make -j4

130
131
gcc
^^^
132

133
1. Install `CMake`_ (3.2 or higher):
134

135
   .. code::
136

137
     brew install cmake
138

139
2. Install **gcc**:
140

141
   .. code::
142

143
144
145
146
147
148
149
150
151
152
153
     brew install gcc

3. Run the following commands:

   .. code::

     git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
     export CXX=g++-7 CC=gcc-7  # replace "7" with version of gcc installed on your machine
     mkdir build ; cd build
     cmake ..
     make -j4
154

155
Also, you may want to read `gcc Tips <./gcc-Tips.rst>`__.
156

157
158
159
160
161
162
163
164
Docker
~~~~~~

Refer to `Docker folder <https://github.com/Microsoft/LightGBM/tree/master/docker>`__.

Build MPI Version
~~~~~~~~~~~~~~~~~

165
166
The default build version of LightGBM is based on socket. LightGBM also supports MPI.
`MPI`_ is a high performance communication approach with `RDMA`_ support.
167
168
169
170
171
172

If you need to run a parallel learning application with high performance communication, you can build the LightGBM with MPI support.

Windows
^^^^^^^

173
174
175
176
177
178
On Windows MPI version of LightGBM can be built using

- **MS MPI** and **Visual Studio**;

- **MS MPI**, **CMake** and **MSBuild**.

179
180
181
182
183
With GUI
********

1. You need to install `MS MPI`_ first. Both ``msmpisdk.msi`` and ``MSMpiSetup.exe`` are needed.

184
2. Install `Visual Studio`_ (2015 or newer).
185
186
187
188
189

3. Download `zip archive`_ and unzip it.

4. Go to ``LightGBM-master/windows`` folder.

190
5. Open ``LightGBM.sln`` file with **Visual Studio**, choose ``Release_mpi`` configuration and click ``BUILD`` -> ``Build Solution (Ctrl+Shift+B)``.
191

192
   If you have errors about **Platform Toolset**, go to ``PROJECT`` -> ``Properties`` -> ``Configuration Properties`` -> ``General`` and select the toolset installed on your machine.
193
194
195
196
197
198
199
200

The exe file will be in ``LightGBM-master/windows/x64/Release_mpi`` folder.

From Command Line
*****************

1. You need to install `MS MPI`_ first. Both ``msmpisdk.msi`` and ``MSMpiSetup.exe`` are needed.

201
2. Install `Git for Windows`_, `CMake`_ (3.8 or higher) and `MSBuild`_ (**MSBuild** is not needed if **Visual Studio** (2015 or newer) is already installed).
202
203
204
205
206
207
208
209
210
211
212
213
214
215

3. Run the following commands:

   .. code::

     git clone --recursive https://github.com/Microsoft/LightGBM
     cd LightGBM
     mkdir build
     cd build
     cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DUSE_MPI=ON ..
     cmake --build . --target ALL_BUILD --config Release

The exe and dll files will be in ``LightGBM/Release`` folder.

216
**Note**: Building MPI version by **MinGW** is not supported due to the miss of MPI library in it.
217
218
219
220

Linux
^^^^^

221
On Linux MPI version of LightGBM can be built using **Open MPI**, **CMake** and **gcc** or **Clang**.
222

223
1. Install `Open MPI`_.
224

225
2. Install `CMake`_.
226

227
228
229
230
231
232
233
234
3. Run the following commands:

   .. code::

     git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
     mkdir build ; cd build
     cmake -DUSE_MPI=ON ..
     make -j4
235
236
237

**Note**: glibc >= 2.14 is required.

238
239
macOS
^^^^^
240

241
On macOS MPI version of LightGBM can be built using **Open MPI**, **CMake** and **Apple Clang** or **gcc**.
242

243
244
Apple Clang
***********
245

246
Only **Apple Clang** version 8.1 or higher is supported.
247

248
1. Install `CMake`_ (3.12 or higher):
249

250
   .. code::
251

252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
     brew install cmake

2. Install **OpenMP**:

   .. code::

     brew install libomp

3. Install **Open MPI**:

   .. code::

     brew install open-mpi

4. Run the following commands:

   .. code::

     git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
     mkdir build ; cd build
     cmake -DUSE_MPI=ON ..
     make -j4

gcc
***

1. Install `CMake`_ (3.2 or higher):

   .. code::

     brew install cmake

2. Install **gcc**:

   .. code::

     brew install gcc

3. Install **Open MPI**:

   .. code::

     brew install open-mpi

4. Run the following commands:

   .. code::

     git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
     export CXX=g++-7 CC=gcc-7  # replace "7" with version of gcc installed on your machine
     mkdir build ; cd build
     cmake -DUSE_MPI=ON ..
     make -j4
305
306
307
308
309
310
311

Build GPU Version
~~~~~~~~~~~~~~~~~

Linux
^^^^^

312
313
On Linux GPU version of LightGBM can be built using **OpenCL**, **Boost**, **CMake** and **gcc** or **Clang**.

314
315
The following dependencies should be installed before compilation:

316
-  **OpenCL** 1.2 headers and libraries, which is usually provided by GPU manufacture.
317
318
319

   The generic OpenCL ICD packages (for example, Debian package ``cl-icd-libopencl1`` and ``cl-icd-opencl-dev``) can also be used.

320
-  **libboost** 1.56 or later (1.61 or later is recommended).
321
322
323
324
325

   We use Boost.Compute as the interface to GPU, which is part of the Boost library since version 1.61. However, since we include the source code of Boost.Compute as a submodule, we only require the host has Boost 1.56 or later installed. We also use Boost.Align for memory allocation. Boost.Compute requires Boost.System and Boost.Filesystem to store offline kernel cache.

   The following Debian packages should provide necessary Boost libraries: ``libboost-dev``, ``libboost-system-dev``, ``libboost-filesystem-dev``.

326
-  **CMake** 3.2 or later.
327
328
329
330
331
332
333
334

To build LightGBM GPU version, run the following commands:

.. code::

  git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
  mkdir build ; cd build
  cmake -DUSE_GPU=1 ..
335
336
  # if you have installed NVIDIA CUDA to a customized location, you should specify paths to OpenCL headers and library like the following:
  # cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/ ..
337
338
339
340
341
  make -j4

Windows
^^^^^^^

342
On Windows GPU version of LightGBM can be built using **OpenCL**, **Boost**, **CMake** and **MSBuild** or **MinGW**.
343

344
If you use **MinGW**, the build procedure is similar to the build on Linux. Refer to `GPU Windows Compilation <./GPU-Windows.rst>`__ to get more details.
345

346
347
348
Following procedure is for the **MSVC** (Microsoft Visual C++) build.

1. Install `Git for Windows`_, `CMake`_ (3.8 or higher) and `MSBuild`_ (**MSBuild** is not needed if **Visual Studio** (2015 or newer) is installed).
349
350
351
352
353

2. Install **OpenCL** for Windows. The installation depends on the brand (NVIDIA, AMD, Intel) of your GPU card.

   - For running on Intel, get `Intel SDK for OpenCL`_.

354
   - For running on AMD, get AMD APP SDK.
355
356
357

   - For running on NVIDIA, get `CUDA Toolkit`_.

358
359
   Further reading and correspondence table: `GPU SDK Correspondence and Device Targeting Table <./GPU-Targets.rst>`__.

360
361
3. Install `Boost Binary`_.

362
   **Note**: Match your Visual C++ version:
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
   
   Visual Studio 2015 -> ``msvc-14.0-64.exe``,

   Visual Studio 2017 -> ``msvc-14.1-64.exe``.

4. Run the following commands:

   .. code::

     Set BOOST_ROOT=C:\local\boost_1_64_0\
     Set BOOST_LIBRARYDIR=C:\local\boost_1_64_0\lib64-msvc-14.0
     git clone --recursive https://github.com/Microsoft/LightGBM
     cd LightGBM
     mkdir build
     cd build
     cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DUSE_GPU=1 ..
     cmake --build . --target ALL_BUILD --config Release

381
   **Note**: ``C:\local\boost_1_64_0\`` and ``C:\local\boost_1_64_0\lib64-msvc-14.0`` are locations of your **Boost** binaries. You also can set them to the environment variable to avoid ``Set ...`` commands when build.
382
383
384
385
386
387

Docker
^^^^^^

Refer to `GPU Docker folder <https://github.com/Microsoft/LightGBM/tree/master/docker/gpu>`__.

388
389
390
Build HDFS Version
~~~~~~~~~~~~~~~~~~

391
**Note**: Installation process of HDFS version is untested.
392
393
394
395

Linux
^^^^^

396
On Linux HDFS version of LightGBM can be built using **CMake** and **gcc** or **Clang**.
397

398
1. Install `CMake`_.
fanliwen's avatar
fanliwen committed
399
400
401
402
403
404
405
406
407
408

2. Run the following commands:

   .. code::

     git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
     mkdir build ; cd build
     cmake -DUSE_HDFS=ON ..
     make -j4

409
410
411
412
413
414
Build Java Wrapper
~~~~~~~~~~~~~~~~~~

Linux
^^^^^

415
On Linux Java wrapper of LightGBM can be built using **Java**, **SWIG**, **CMake** and **gcc** or **Clang**.
416

417
1. Install `CMake`_, `SWIG`_ and **Java**.
418

419
2. Run the following commands:
420

421
422
423
424
425
426
   .. code::

     git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
     mkdir build ; cd build
     cmake -DUSE_SWIG=ON ..
     make _lightgbm_swig -j4
427

428
This will generate a JAR file containing the LightGBM `C API <./Development-Guide.rst#c-api>`__ wrapped by **SWIG**.
429

430
431
432
433
434
435
.. _Python-package: https://github.com/Microsoft/LightGBM/tree/master/python-package

.. _R-package: https://github.com/Microsoft/LightGBM/tree/master/R-package

.. _zip archive: https://github.com/Microsoft/LightGBM/archive/master.zip

436
.. _Visual Studio: https://visualstudio.microsoft.com/downloads/
437
438
439
440
441

.. _Git for Windows: https://git-scm.com/download/win

.. _CMake: https://cmake.org/

442
.. _MSBuild: https://visualstudio.microsoft.com/downloads/
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458

.. _MinGW-w64: https://mingw-w64.org/doku.php/download

.. _MPI: https://en.wikipedia.org/wiki/Message_Passing_Interface

.. _RDMA: https://en.wikipedia.org/wiki/Remote_direct_memory_access

.. _MS MPI: https://www.microsoft.com/en-us/download/details.aspx?id=49926

.. _Open MPI: https://www.open-mpi.org/

.. _Intel SDK for OpenCL: https://software.intel.com/en-us/articles/opencl-drivers

.. _CUDA Toolkit: https://developer.nvidia.com/cuda-downloads

.. _Boost Binary: https://sourceforge.net/projects/boost/files/boost-binaries/1.64.0/
459
460

.. _SWIG: http://www.swig.org/download.html