Installation-Guide.rst 21.5 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
Also you can download artifacts of the latest successful build in master branch: |download artifacts|.

10
11
12
13
.. contents:: **Contents**
    :depth: 1
    :local:
    :backlinks: none
14

15
16
17
Windows
~~~~~~~

18
19
20
21
On Windows LightGBM can be built using

- **Visual Studio**;

22
- **CMake** and **VS Build Tools**;
23
24

- **CMake** and **MinGW**.
25

26
27
Visual Studio (or VS Build Tools)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28
29
30
31

With GUI
********

32
1. Install `Visual Studio`_ (2015 or newer).
33
34
35
36
37

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

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

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

40
   If you have errors about **Platform Toolset**, go to ``PROJECT`` -> ``Properties`` -> ``Configuration Properties`` -> ``General`` and select the toolset installed on your machine.
41

42
The ``.exe`` file will be in ``LightGBM-master/windows/x64/Release`` folder.
43
44
45
46

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

47
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).
48
49
50
51
52

2. Run the following commands:

   .. code::

53
     git clone --recursive https://github.com/microsoft/LightGBM
54
55
56
     cd LightGBM
     mkdir build
     cd build
57
     cmake -A x64 ..
58
59
     cmake --build . --target ALL_BUILD --config Release

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

62
63
MinGW-w64
^^^^^^^^^
64
65
66
67
68
69
70

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

2. Run the following commands:

   .. code::

71
     git clone --recursive https://github.com/microsoft/LightGBM
72
73
74
75
76
77
     cd LightGBM
     mkdir build
     cd build
     cmake -G "MinGW Makefiles" ..
     mingw32-make.exe -j4

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

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

82
83
It is recommended to use **Visual Studio** for its better multithreading efficiency in **Windows** for many-core systems
(see `Question 4 <./FAQ.rst#i-am-using-windows-should-i-use-visual-studio-or-mingw-for-compiling-lightgbm>`__ and `Question 8 <./FAQ.rst#cpu-usage-is-low-like-10-in-windows-when-using-lightgbm-on-very-large-datasets-with-many-core-systems>`__).
84
85

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

87
88
89
Linux
~~~~~

90
On Linux LightGBM can be built using **CMake** and **gcc** or **Clang**.
91

92
1. Install `CMake`_.
93

94
95
96
97
2. Run the following commands:

   .. code::

98
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
99
100
101
     mkdir build ; cd build
     cmake ..
     make -j4
102
103
104

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

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

107
108
macOS
~~~~~
109

110
111
112
113
On macOS LightGBM can be built using **CMake** and **Apple Clang** or **gcc**.

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

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

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

119
   .. code::
Nikita Titov's avatar
Nikita Titov committed
120

121
     brew install cmake
fanliwen's avatar
fanliwen committed
122

123
2. Install **OpenMP**:
fanliwen's avatar
fanliwen committed
124
125
126
127

   .. code::

     brew install libomp
128
129
130
131
132

3. Run the following commands:

   .. code::

133
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
fanliwen's avatar
fanliwen committed
134
     mkdir build ; cd build
135
136
137
138
139
140
141
142
143
144
145

     # For Mojave (10.14)
     cmake \
       -DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include" \
       -DOpenMP_C_LIB_NAMES="omp" \
       -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include" \
       -DOpenMP_CXX_LIB_NAMES="omp" \
       -DOpenMP_omp_LIBRARY=$(brew --prefix libomp)/lib/libomp.dylib \
       ..

     # For High Sierra or earlier (<= 10.13)
fanliwen's avatar
fanliwen committed
146
     cmake ..
147

fanliwen's avatar
fanliwen committed
148
149
     make -j4

150
151
gcc
^^^
152

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

155
   .. code::
156

157
     brew install cmake
158

159
2. Install **gcc**:
160

161
   .. code::
162

163
164
165
166
167
168
     brew install gcc

3. Run the following commands:

   .. code::

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

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

177
178
179
Docker
~~~~~~

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

182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
Build Threadless Version (not Recommended)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The default build version of LightGBM is based on OpenMP.
However, you can build the LightGBM without OpenMP support, but it is **strongly not recommended**.

Windows
^^^^^^^

On Windows version of LightGBM without OpenMP support can be built using

- **Visual Studio**;

- **CMake** and **VS Build Tools**;

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

Visual Studio (or VS Build Tools)
*********************************

With GUI
--------

1. Install `Visual Studio`_ (2015 or newer).

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

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

4. Open ``LightGBM.sln`` file with **Visual Studio**.

5. Go to ``PROJECT`` -> ``Properties`` -> ``Configuration Properties`` -> ``C/C++`` -> ``Language`` and change the ``OpenMP Support`` property to ``No (/openmp-)``.

6. Get back to the project's main screen, then choose ``Release`` configuration and click ``BUILD`` -> ``Build Solution (Ctrl+Shift+B)``.

   If you have errors about **Platform Toolset**, go to ``PROJECT`` -> ``Properties`` -> ``Configuration Properties`` -> ``General`` and select the toolset installed on your machine.

219
The ``.exe`` file will be in ``LightGBM-master/windows/x64/Release`` folder.
220
221
222
223
224
225
226
227
228
229

From Command Line
-----------------

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

2. Run the following commands:

   .. code::

230
     git clone --recursive https://github.com/microsoft/LightGBM
231
232
233
     cd LightGBM
     mkdir build
     cd build
234
     cmake -A x64 -DUSE_OPENMP=OFF ..
235
236
     cmake --build . --target ALL_BUILD --config Release

237
The ``.exe`` and ``.dll`` files will be in ``LightGBM/Release`` folder.
238
239
240
241
242
243
244
245
246
247

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

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

2. Run the following commands:

   .. code::

248
     git clone --recursive https://github.com/microsoft/LightGBM
249
250
251
252
253
254
     cd LightGBM
     mkdir build
     cd build
     cmake -G "MinGW Makefiles" -DUSE_OPENMP=OFF ..
     mingw32-make.exe -j4

255
The ``.exe`` and ``.dll`` files will be in ``LightGBM/`` folder.
256
257
258
259
260
261
262
263
264
265
266
267
268
269

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

Linux
^^^^^

On Linux version of LightGBM without OpenMP support can be built using **CMake** and **gcc** or **Clang**.

1. Install `CMake`_.

2. Run the following commands:

   .. code::

270
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
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
     mkdir build ; cd build
     cmake -DUSE_OPENMP=OFF ..
     make -j4

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

macOS
^^^^^

On macOS version of LightGBM without OpenMP support can be built using **CMake** and **Apple Clang** or **gcc**.

Apple Clang
***********

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

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

   .. code::

     brew install cmake

2. Run the following commands:

   .. code::

297
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
     mkdir build ; cd build
     cmake -DUSE_OPENMP=OFF ..
     make -j4

gcc
***

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

   .. code::

     brew install cmake

2. Install **gcc**:

   .. code::

     brew install gcc

3. Run the following commands:

   .. code::

321
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
322
323
324
325
326
     export CXX=g++-7 CC=gcc-7  # replace "7" with version of gcc installed on your machine
     mkdir build ; cd build
     cmake -DUSE_OPENMP=OFF ..
     make -j4

327
328
329
Build MPI Version
~~~~~~~~~~~~~~~~~

330
331
The default build version of LightGBM is based on socket. LightGBM also supports MPI.
`MPI`_ is a high performance communication approach with `RDMA`_ support.
332
333
334
335
336
337

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

Windows
^^^^^^^

338
339
340
341
On Windows MPI version of LightGBM can be built using

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

342
- **MS MPI**, **CMake** and **VS Build Tools**.
343

344
345
346
With GUI
********

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

349
2. Install `Visual Studio`_ (2015 or newer).
350
351
352
353
354

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

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

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

357
   If you have errors about **Platform Toolset**, go to ``PROJECT`` -> ``Properties`` -> ``Configuration Properties`` -> ``General`` and select the toolset installed on your machine.
358

359
The ``.exe`` file will be in ``LightGBM-master/windows/x64/Release_mpi`` folder.
360
361
362
363

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

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

366
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).
367
368
369
370
371

3. Run the following commands:

   .. code::

372
     git clone --recursive https://github.com/microsoft/LightGBM
373
374
375
     cd LightGBM
     mkdir build
     cd build
376
     cmake -A x64 -DUSE_MPI=ON ..
377
378
     cmake --build . --target ALL_BUILD --config Release

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

381
**Note**: Building MPI version by **MinGW** is not supported due to the miss of MPI library in it.
382
383
384
385

Linux
^^^^^

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

388
1. Install `Open MPI`_.
389

390
2. Install `CMake`_.
391

392
393
394
395
3. Run the following commands:

   .. code::

396
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
397
398
399
     mkdir build ; cd build
     cmake -DUSE_MPI=ON ..
     make -j4
400
401
402

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

403
404
macOS
^^^^^
405

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

408
409
Apple Clang
***********
410

411
Only **Apple Clang** version 8.1 or higher is supported.
412

413
1. Install `CMake`_ (3.12 or higher):
414

415
   .. code::
416

417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
     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::

435
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
436
     mkdir build ; cd build
437
438
439
440
441
442
443
444
445
446
447
448

     # For Mojave (10.14)
     cmake \
       -DUSE_MPI=ON \
       -DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include" \
       -DOpenMP_C_LIB_NAMES="omp" \
       -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include" \
       -DOpenMP_CXX_LIB_NAMES="omp" \
       -DOpenMP_omp_LIBRARY=$(brew --prefix libomp)/lib/libomp.dylib \
       ..

     # For High Sierra or earlier (<= 10.13)
449
     cmake -DUSE_MPI=ON ..
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
     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::

478
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
479
480
481
482
     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
483
484
485
486
487
488
489

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

Linux
^^^^^

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

492
493
The following dependencies should be installed before compilation:

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

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

498
-  **libboost** 1.56 or later (1.61 or later is recommended).
499
500
501
502
503

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

504
-  **CMake** 3.2 or later.
505
506
507
508
509

To build LightGBM GPU version, run the following commands:

.. code::

510
  git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
511
512
  mkdir build ; cd build
  cmake -DUSE_GPU=1 ..
513
514
  # 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/ ..
515
516
517
518
519
  make -j4

Windows
^^^^^^^

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

522
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.
523

524
525
Following procedure is for the **MSVC** (Microsoft Visual C++) build.

526
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).
527
528
529
530
531

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

532
   - For running on AMD, get AMD APP SDK.
533
534
535

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

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

Nikita Titov's avatar
Nikita Titov committed
538
3. Install `Boost Binaries`_.
539

540
   **Note**: Match your Visual C++ version:
541
542
543
   
   Visual Studio 2015 -> ``msvc-14.0-64.exe``,

544
545
546
   Visual Studio 2017 -> ``msvc-14.1-64.exe``,

   Visual Studio 2019 -> ``msvc-14.2-64.exe``.
547
548
549
550
551

4. Run the following commands:

   .. code::

552
     git clone --recursive https://github.com/microsoft/LightGBM
553
554
555
     cd LightGBM
     mkdir build
     cd build
556
557
558
     cmake -A x64 -DUSE_GPU=1 -DBOOST_ROOT=C:/local/boost_1_63_0 -DBOOST_LIBRARYDIR=C:/local/boost_1_63_0/lib64-msvc-14.0 ..
     # if you have installed NVIDIA CUDA to a customized location, you should specify paths to OpenCL headers and library like the following:
     # cmake -A x64 -DUSE_GPU=1 -DBOOST_ROOT=C:/local/boost_1_63_0 -DBOOST_LIBRARYDIR=C:/local/boost_1_63_0/lib64-msvc-14.0 -DOpenCL_LIBRARY="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/lib/x64/OpenCL.lib" -DOpenCL_INCLUDE_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/include" ..
559
560
     cmake --build . --target ALL_BUILD --config Release

561
   **Note**: ``C:/local/boost_1_63_0`` and ``C:/local/boost_1_63_0/lib64-msvc-14.0`` are locations of your **Boost** binaries (assuming you've downloaded 1.63.0 version for Visual Studio 2015).
562
563
564
565

Docker
^^^^^^

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

568
569
570
Build HDFS Version
~~~~~~~~~~~~~~~~~~

571
HDFS version of LightGBM was tested on CDH-5.14.4 cluster.
572
573
574
575

Linux
^^^^^

576
On Linux HDFS version of LightGBM can be built using **CMake** and **gcc**.
577

578
1. Install `CMake`_.
fanliwen's avatar
fanliwen committed
579
580
581
582
583

2. Run the following commands:

   .. code::

584
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
fanliwen's avatar
fanliwen committed
585
586
     mkdir build ; cd build
     cmake -DUSE_HDFS=ON ..
587
588
589
590
591
592
     # if you have installed HDFS to a customized location, you should specify paths to HDFS headers (hdfs.h) and library (libhdfs.so) like the following:
     # cmake \
     #   -DUSE_HDFS=ON \
     #   -DHDFS_LIB="/opt/cloudera/parcels/CDH-5.14.4-1.cdh5.14.4.p0.3/lib64/libhdfs.so" \
     #   -DHDFS_INCLUDE_DIR="/opt/cloudera/parcels/CDH-5.14.4-1.cdh5.14.4.p0.3/include/" \
     #   ..
fanliwen's avatar
fanliwen committed
593
594
     make -j4

595
596
597
Build Java Wrapper
~~~~~~~~~~~~~~~~~~

598
599
600
601
602
By the following instructions you can generate a JAR file containing the LightGBM `C API <./Development-Guide.rst#c-api>`__ wrapped by **SWIG**.

Windows
^^^^^^^

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

605
606
VS Build Tools
**************
607

608
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).
609
610
611
612
613
614
615

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

3. Run the following commands:

   .. code::

616
     git clone --recursive https://github.com/microsoft/LightGBM
617
618
619
     cd LightGBM
     mkdir build
     cd build
620
     cmake -A x64 -DUSE_SWIG=ON ..
621
622
     cmake --build . --target ALL_BUILD --config Release

623
The ``.jar`` file will be in ``LightGBM/build`` folder and the ``.dll`` files will be in ``LightGBM/Release`` folder.
624
625
626
627
628
629
630
631
632
633
634
635

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::

636
     git clone --recursive https://github.com/microsoft/LightGBM
637
638
639
640
641
642
     cd LightGBM
     mkdir build
     cd build
     cmake -G "MinGW Makefiles" -DUSE_SWIG=ON ..
     mingw32-make.exe -j4

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

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

647
648
649
It is recommended to use **VS Build Tools (Visual Studio)** for its better multithreading efficiency in **Windows** for many-core systems
(see `Question 4 <./FAQ.rst#i-am-using-windows-should-i-use-visual-studio-or-mingw-for-compiling-lightgbm>`__ and `Question 8 <./FAQ.rst#cpu-usage-is-low-like-10-in-windows-when-using-lightgbm-on-very-large-datasets-with-many-core-systems>`__).

650
651
652

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

653
654
655
Linux
^^^^^

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

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

660
2. Run the following commands:
661

662
663
   .. code::

664
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
665
666
     mkdir build ; cd build
     cmake -DUSE_SWIG=ON ..
667
     make -j4
668

669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
macOS
^^^^^

On macOS Java wrapper of LightGBM can be built using **Java**, **SWIG**, **CMake** and **Apple Clang** or **gcc**.

First, install `SWIG`_ and **Java** (also make sure that ``JAVA_HOME`` is set properly).
Then, either follow the **Apple Clang** or **gcc** installation instructions below.

Apple Clang
***********

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

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

   .. code::

     brew install cmake

2. Install **OpenMP**:

   .. code::

     brew install libomp

3. Run the following commands:

   .. code::

698
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
     mkdir build ; cd build

     # For Mojave (10.14)
     cmake \
       -DUSE_SWIG=ON \
       -DAPPLE_OUTPUT_DYLIB=ON \
       -DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include" \
       -DOpenMP_C_LIB_NAMES="omp" \
       -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include" \
       -DOpenMP_CXX_LIB_NAMES="omp" \
       -DOpenMP_omp_LIBRARY=$(brew --prefix libomp)/lib/libomp.dylib \
       ..

     # For High Sierra or earlier (<= 10.13)
     cmake -DUSE_SWIG=ON -DAPPLE_OUTPUT_DYLIB=ON ..

     make -j4

gcc
***

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

   .. code::

     brew install cmake

2. Install **gcc**:

   .. code::

     brew install gcc

3. Run the following commands:

   .. code::

736
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
737
738
739
740
741
742
743
744
     export CXX=g++-7 CC=gcc-7  # replace "7" with version of gcc installed on your machine
     mkdir build ; cd build
     cmake -DUSE_SWIG=ON -DAPPLE_OUTPUT_DYLIB=ON ..
     make -j4

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


745
746
747
.. |download artifacts| image:: ./_static/images/artifacts-not-available.svg
   :target: https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html

748
.. _Python-package: https://github.com/microsoft/LightGBM/tree/master/python-package
749

750
.. _R-package: https://github.com/microsoft/LightGBM/tree/master/R-package
751

752
.. _zip archive: https://github.com/microsoft/LightGBM/archive/master.zip
753

754
.. _Visual Studio: https://visualstudio.microsoft.com/downloads/
755
756
757
758
759

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

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

760
.. _VS Build Tools: https://visualstudio.microsoft.com/downloads/
761
762
763
764
765
766
767

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

768
.. _MS MPI: https://www.microsoft.com/en-us/download/details.aspx?id=57467
769
770
771
772
773
774
775

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

Nikita Titov's avatar
Nikita Titov committed
776
.. _Boost Binaries: https://bintray.com/boostorg/release/boost-binaries/_latestVersion#files
777
778

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