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

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

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

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
**Contents**

-  `Windows <#windows>`__

-  `Linux <#linux>`__

-  `macOS <#macos>`__

-  `Docker <#docker>`__

-  `MPI Version <#build-mpi-version>`__

-  `GPU Version <#build-gpu-version>`__

-  `HDFS Version <#build-hdfs-version>`__

-  `Java Wrapper <#build-java-wrapper>`__

26
27
28
Windows
~~~~~~~

29
30
31
32
On Windows LightGBM can be built using

- **Visual Studio**;

33
- **CMake** and **VS Build Tools**;
34
35

- **CMake** and **MinGW**.
36

37
38
Visual Studio (or VS Build Tools)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39
40
41
42

With GUI
********

43
1. Install `Visual Studio`_ (2015 or newer).
44
45
46
47
48

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

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

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

51
   If you have errors about **Platform Toolset**, go to ``PROJECT`` -> ``Properties`` -> ``Configuration Properties`` -> ``General`` and select the toolset installed on your machine.
52
53
54
55
56
57

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

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

58
1. Install `Git for Windows`_, `CMake`_ (3.8 or higher) and `VS Build Tools`_ (**VS Build Tools** is not needed if **Visual Studio** (2015 or newer) is already installed).
59
60
61
62
63
64
65
66
67
68
69
70
71
72

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.

73
74
MinGW-w64
^^^^^^^^^
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

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.

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

93
94
95
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>`__.
96

97
98
99
Linux
~~~~~

100
On Linux LightGBM can be built using **CMake** and **gcc** or **Clang**.
101

102
1. Install `CMake`_.
103

104
105
106
107
108
109
110
111
2. Run the following commands:

   .. code::

     git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
     mkdir build ; cd build
     cmake ..
     make -j4
112
113
114

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

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

117
118
macOS
~~~~~
119

120
121
122
123
On macOS LightGBM can be built using **CMake** and **Apple Clang** or **gcc**.

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

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

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

129
   .. code::
Nikita Titov's avatar
Nikita Titov committed
130

131
     brew install cmake
fanliwen's avatar
fanliwen committed
132

133
2. Install **OpenMP**:
fanliwen's avatar
fanliwen committed
134
135
136
137

   .. code::

     brew install libomp
138
139
140
141
142

3. Run the following commands:

   .. code::

fanliwen's avatar
fanliwen committed
143
144
145
146
147
     git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
     mkdir build ; cd build
     cmake ..
     make -j4

148
149
gcc
^^^
150

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

153
   .. code::
154

155
     brew install cmake
156

157
2. Install **gcc**:
158

159
   .. code::
160

161
162
163
164
165
166
167
168
169
170
171
     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
172

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

175
176
177
178
179
180
181
182
Docker
~~~~~~

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

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

183
184
The default build version of LightGBM is based on socket. LightGBM also supports MPI.
`MPI`_ is a high performance communication approach with `RDMA`_ support.
185
186
187
188
189
190

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

Windows
^^^^^^^

191
192
193
194
On Windows MPI version of LightGBM can be built using

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

195
- **MS MPI**, **CMake** and **VS Build Tools**.
196

197
198
199
With GUI
********

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

202
2. Install `Visual Studio`_ (2015 or newer).
203
204
205
206
207

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

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

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

210
   If you have errors about **Platform Toolset**, go to ``PROJECT`` -> ``Properties`` -> ``Configuration Properties`` -> ``General`` and select the toolset installed on your machine.
211
212
213
214
215
216

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

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

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

219
2. Install `Git for Windows`_, `CMake`_ (3.8 or higher) and `VS Build Tools`_ (**VS Build Tools** is not needed if **Visual Studio** (2015 or newer) is already installed).
220
221
222
223
224
225
226
227
228
229
230
231
232
233

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.

234
**Note**: Building MPI version by **MinGW** is not supported due to the miss of MPI library in it.
235
236
237
238

Linux
^^^^^

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

241
1. Install `Open MPI`_.
242

243
2. Install `CMake`_.
244

245
246
247
248
249
250
251
252
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
253
254
255

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

256
257
macOS
^^^^^
258

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

261
262
Apple Clang
***********
263

264
Only **Apple Clang** version 8.1 or higher is supported.
265

266
1. Install `CMake`_ (3.12 or higher):
267

268
   .. code::
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
     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
323
324
325
326
327
328
329

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

Linux
^^^^^

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

332
333
The following dependencies should be installed before compilation:

334
-  **OpenCL** 1.2 headers and libraries, which is usually provided by GPU manufacture.
335
336
337

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

338
-  **libboost** 1.56 or later (1.61 or later is recommended).
339
340
341
342
343

   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``.

344
-  **CMake** 3.2 or later.
345
346
347
348
349
350
351
352

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 ..
353
354
  # 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/ ..
355
356
357
358
359
  make -j4

Windows
^^^^^^^

360
On Windows GPU version of LightGBM can be built using **OpenCL**, **Boost**, **CMake** and **VS Build Tools** or **MinGW**.
361

362
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.
363

364
365
Following procedure is for the **MSVC** (Microsoft Visual C++) build.

366
1. Install `Git for Windows`_, `CMake`_ (3.8 or higher) and `VS Build Tools`_ (**VS Build Tools** is not needed if **Visual Studio** (2015 or newer) is installed).
367
368
369
370
371

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`_.

372
   - For running on AMD, get AMD APP SDK.
373
374
375

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

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

378
379
3. Install `Boost Binary`_.

380
   **Note**: Match your Visual C++ version:
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
   
   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

399
   **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.
400
401
402
403
404
405

Docker
^^^^^^

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

406
407
408
Build HDFS Version
~~~~~~~~~~~~~~~~~~

409
**Note**: Installation process of HDFS version is untested.
410
411
412
413

Linux
^^^^^

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

416
1. Install `CMake`_.
fanliwen's avatar
fanliwen committed
417
418
419
420
421
422
423
424
425
426

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

427
428
429
Build Java Wrapper
~~~~~~~~~~~~~~~~~~

430
431
432
433
434
By the following instructions you can generate a JAR file containing the LightGBM `C API <./Development-Guide.rst#c-api>`__ wrapped by **SWIG**.

Windows
^^^^^^^

435
On Windows Java wrapper of LightGBM can be built using **Java**, **SWIG**, **CMake** and **VS Build Tools** or **MinGW**.
436

437
438
VS Build Tools
**************
439

440
1. Install `Git for Windows`_, `CMake`_ (3.8 or higher) and `VS Build Tools`_ (**VS Build Tools** is not needed if **Visual Studio** (2015 or newer) is already installed).
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478

2. Install `SWIG`_ and **Java** (also make sure that ``JAVA_HOME`` is set properly).

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_SWIG=ON ..
     cmake --build . --target ALL_BUILD --config Release

The jar file will be in ``LightGBM/build`` folder and the dll files will be in ``LightGBM/Release`` folder.

MinGW-w64
*********

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

2. Install `SWIG`_ and **Java** (also make sure that ``JAVA_HOME`` is set properly).

3. Run the following commands:

   .. code::

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

The jar file will be in ``LightGBM/build`` folder and the dll files will be in ``LightGBM/`` folder.

**Note**: You may need to run the ``cmake -G "MinGW Makefiles" -DUSE_SWIG=ON ..`` one more time if you encounter the ``sh.exe was found in your PATH`` error.

479
It is recommended to use **VS Build Tools (Visual Studio)** for its better multithreading efficiency in **Windows** for many-core systems (see `FAQ <./FAQ.rst#lightgbm>`__ Question 4 and Question 8).
480
481
482

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

483
484
485
Linux
^^^^^

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

488
1. Install `CMake`_, `SWIG`_ and **Java** (also make sure that ``JAVA_HOME`` is set properly).
489

490
2. Run the following commands:
491

492
493
494
495
496
   .. code::

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

499
500
501
502
503
504
.. _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

505
.. _Visual Studio: https://visualstudio.microsoft.com/downloads/
506
507
508
509
510

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

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

511
.. _VS Build Tools: https://visualstudio.microsoft.com/downloads/
512
513
514
515
516
517
518

.. _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

519
.. _MS MPI: https://www.microsoft.com/en-us/download/details.aspx?id=57467
520
521
522
523
524
525
526
527

.. _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/
528
529

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