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
95
96
97
98
99
100
101
102
103
104
105
106
107

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 ..
     make -j4

GCC/G++
fanliwen's avatar
fanliwen committed
108
^^^^^^^
109
110
111
112
113
114

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

.. code::

  brew install cmake
115
  brew install gcc
116
117
118
119
120
121

Then install LightGBM:

.. code::

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

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

129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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.

150
2. Install `Visual Studio`_ (2015 or newer).
151
152
153
154
155

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

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

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

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

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.

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

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.

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

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.

200
201
macOS
^^^^^
202

203
Install **Open MPI** first:
204
205
206

.. code::

207
  brew install open-mpi
208
209
210
211
212
213
214
  brew install cmake

Then run the following commands:

.. code::

  git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
215
  export CXX=g++-7 CC=gcc-7  # replace 7 with version of gcc installed on your machine
216
217
218
219
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
  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 ..
247
248
  # 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/ ..
249
250
251
252
253
  make -j4

Windows
^^^^^^^

254
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.
255

256
Following procedure is for the MSVC (Microsoft Visual C++) build.
257

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

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

264
   - For running on AMD, get AMD APP SDK.
265
266
267

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

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

270
271
3. Install `Boost Binary`_.

272
   **Note**: Match your Visual C++ version:
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
   
   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>`__.

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
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
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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
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++
*******
370
371
372
373
374
375
376
377
378
379
380
381
382

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
383
  export CXX=g++-7 CC=gcc-7  # replace 7 with version of gcc installed on your machine
384
385
386
387
  mkdir build ; cd build
  cmake -DUSE_HDFS=ON ..
  make -j4

388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
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.

407
408
409
410
411
412
.. _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

413
.. _Visual Studio: https://visualstudio.microsoft.com/downloads/
414
415
416
417
418

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

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

419
.. _MSBuild: https://visualstudio.microsoft.com/downloads/
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435

.. _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/
436
437

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