Installation-Guide.rst 11 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
90
91
92
93
94
95
96

LightGBM depends on **OpenMP** for compiling, which isn't supported by Apple Clang.

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

.. code::

  brew install cmake
97
  brew install gcc
98
99
100
101
102
103

Then install LightGBM:

.. code::

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

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

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
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.

132
2. Install `Visual Studio`_ (2015 or newer).
133
134
135
136
137

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

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

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

140
   If you have errors about **Platform Toolset**, go to ``PROJECT``->\ ``Properties``->\ ``Configuration Properties``->\ ``General`` and select the toolset installed on your machine.
141
142
143
144
145
146
147
148

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.

149
2. Install `Git for Windows`_, `CMake`_ (3.8 or higher) and `MSBuild`_ (MSBuild is not needed if **Visual Studio** (2015 or newer) is installed).
150
151
152
153
154
155
156
157
158
159
160
161
162
163

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.

164
**Note**: Building MPI version by **MinGW** is not supported due to the miss of MPI library in it.
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181

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.

182
183
macOS
^^^^^
184

185
Install **Open MPI** first:
186
187
188

.. code::

189
  brew install open-mpi
190
191
192
193
194
195
196
  brew install cmake

Then run the following commands:

.. code::

  git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
197
  export CXX=g++-7 CC=gcc-7  # replace 7 with version of gcc installed on your machine
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
  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 ..
229
230
  # 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/ ..
231
232
233
234
235
  make -j4

Windows
^^^^^^^

236
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.
237

238
Following procedure is for the MSVC (Microsoft Visual C++) build.
239

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

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

246
   - For running on AMD, get AMD APP SDK.
247
248
249

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

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

252
253
3. Install `Boost Binary`_.

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

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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
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
^^^^^

LightGBM depends on **OpenMP** for compiling, which isn't supported by Apple Clang.

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
347
  export CXX=g++-7 CC=gcc-7  # replace 7 with version of gcc installed on your machine
348
349
350
351
  mkdir build ; cd build
  cmake -DUSE_HDFS=ON ..
  make -j4

352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
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.

371
372
373
374
375
376
.. _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

377
.. _Visual Studio: https://visualstudio.microsoft.com/downloads/
378
379
380
381
382

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

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

383
.. _MSBuild: https://visualstudio.microsoft.com/downloads/
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399

.. _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/
400
401

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