Installation-Guide.rst 11.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Installation Guide
==================

Here is the guide for the build of CLI version.

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

Windows
~~~~~~~

LightGBM can use Visual Studio, MSBuild with CMake or MinGW to build in Windows.

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

With GUI
********

19
1. Install `Visual Studio`_ (2015 or newer).
20
21
22
23
24

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

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

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

27
   If you have errors about **Platform Toolset**, go to ``PROJECT``->\ ``Properties``->\ ``Configuration Properties``->\ ``General`` and select the toolset installed on your machine.
28
29
30
31
32
33

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

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

34
1. Install `Git for Windows`_, `CMake`_ (3.8 or higher) and `MSBuild`_ (**MSBuild** is not needed if **Visual Studio** (2015 or newer) is installed).
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

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.

MinGW64
^^^^^^^

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.

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

Yorway's avatar
Yorway committed
69
Also you may want to read `gcc Tips <./gcc-Tips.rst>`__.
70

71
72
73
Linux
~~~~~

74
LightGBM uses **CMake** to build. Run the following commands:
75
76
77
78
79
80
81
82
83
84

.. code::

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

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

Yorway's avatar
Yorway committed
85
Also you may want to read `gcc Tips <./gcc-Tips.rst>`__.
86

87
88
macOS
~~~~~
89

fanliwen's avatar
fanliwen committed
90
LightGBM can use Apple Clang (9.0 or higher), or GCC/G++ to build in macOS.
fanliwen's avatar
fanliwen committed
91

fanliwen's avatar
fanliwen committed
92
93
Apple Clang (9.0 or higher)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
fanliwen's avatar
fanliwen committed
94

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

97
   .. code::
Nikita Titov's avatar
Nikita Titov committed
98

99
     brew install --HEAD cmake
fanliwen's avatar
fanliwen committed
100
101
102
103
104
105
106
107
108
109
110
111

2. Run the following commands:

   .. code::

     brew install libomp
     git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
     mkdir build ; cd build
     cmake ..
     make -j4

GCC/G++
fanliwen's avatar
fanliwen committed
112
^^^^^^^
113
114
115
116
117
118

Please install **gcc/g++** by using the following commands:

.. code::

  brew install cmake
119
  brew install gcc
120
121
122
123
124
125

Then install LightGBM:

.. code::

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

Yorway's avatar
Yorway committed
131
Also you may want to read `gcc Tips <./gcc-Tips.rst>`__.
132

133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
Docker
~~~~~~

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

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

The default build version of LightGBM is based on socket. LightGBM also supports `MPI`_.
MPI is a high performance communication approach with `RDMA`_ support.

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

Windows
^^^^^^^

With GUI
********

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

154
2. Install `Visual Studio`_ (2015 or newer).
155
156
157
158
159

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

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

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

162
   If you have errors about **Platform Toolset**, go to ``PROJECT``->\ ``Properties``->\ ``Configuration Properties``->\ ``General`` and select the toolset installed on your machine.
163
164
165
166
167
168
169
170

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.

171
2. Install `Git for Windows`_, `CMake`_ (3.8 or higher) and `MSBuild`_ (MSBuild is not needed if **Visual Studio** (2015 or newer) is installed).
172
173
174
175
176
177
178
179
180
181
182
183
184
185

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.

186
**Note**: Building MPI version by **MinGW** is not supported due to the miss of MPI library in it.
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203

Linux
^^^^^

You need to install `Open MPI`_ first.

Then 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

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

204
205
macOS
^^^^^
206

207
Install **Open MPI** first:
208
209
210

.. code::

211
  brew install open-mpi
212
213
214
215
216
217
218
  brew install cmake

Then run the following commands:

.. code::

  git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
219
  export CXX=g++-7 CC=gcc-7  # replace 7 with version of gcc installed on your machine
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
  mkdir build ; cd build
  cmake -DUSE_MPI=ON ..
  make -j4

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

Linux
^^^^^

The following dependencies should be installed before compilation:

-  OpenCL 1.2 headers and libraries, which is usually provided by GPU manufacture.

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

-  libboost 1.56 or later (1.61 or later recommended).

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

-  CMake 3.2 or later.

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 ..
251
252
  # 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/ ..
253
254
255
256
257
  make -j4

Windows
^^^^^^^

258
If you use **MinGW**, the build procedure are similar to the build in Linux. Refer to `GPU Windows Compilation <./GPU-Windows.rst>`__ to get more details.
259

260
Following procedure is for the MSVC (Microsoft Visual C++) build.
261

262
1. Install `Git for Windows`_, `CMake`_ (3.8 or higher) and `MSBuild`_ (MSBuild is not needed if **Visual Studio** (2015 or newer) is installed).
263
264
265
266
267

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

268
   - For running on AMD, get AMD APP SDK.
269
270
271

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

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

274
275
3. Install `Boost Binary`_.

276
   **Note**: Match your Visual C++ version:
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
   
   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

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

Docker
^^^^^^

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

302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
Build HDFS Version
~~~~~~~~~~~~~~~~~~

Windows
^^^^^^^

Visual Studio (or MSBuild)
**************************

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

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

MinGW64
*******

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" -DUSE_HDFS=ON ..
     mingw32-make.exe -j4

Linux
^^^^^

LightGBM uses **CMake** to build. 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

macOS
^^^^^

fanliwen's avatar
fanliwen committed
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
LightGBM can use Apple Clang (9.0 or higher), or GCC/G++ to build in macOS.

Apple Clang (9.0 or higher)
***************************

1. Install `CMake`_ (3.12 or higher).

2. Run the following commands:

   .. code::

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

GCC/G++
*******
374
375
376
377
378
379
380
381
382
383
384
385
386

Please install **gcc/g++** by using the following commands:

.. code::

  brew install cmake
  brew install gcc

Then install LightGBM:

.. code::

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

392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
Build Java Wrapper
~~~~~~~~~~~~~~~~~~

Linux
^^^^^

You need to install `SWIG`_ and **Java** first.

Then run the following commands:

.. code::

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

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

411
412
413
414
415
416
.. _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

417
.. _Visual Studio: https://visualstudio.microsoft.com/downloads/
418
419
420
421
422

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

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

423
.. _MSBuild: https://visualstudio.microsoft.com/downloads/
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439

.. _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/
440
441

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