"R-package/vscode:/vscode.git/clone" did not exist on "9489f878b3568e70b441e5df602483e116f24cc6"
Installation-Guide.rst 22 KB
Newer Older
1
2
3
Installation Guide
==================

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

6
7
8
9
All instructions below are aimed to compile 64-bit version of LightGBM.
It is worth to compile 32-bit version only in very rare special cases of environmental limitations.
32-bit version is slow and untested, so use it on your own risk and don't forget to adjust some commands in this guide.

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

12
13
Also you can download artifacts of the latest successful build in master branch: |download artifacts|.

14
15
16
17
.. contents:: **Contents**
    :depth: 1
    :local:
    :backlinks: none
18

19
20
21
Windows
~~~~~~~

22
23
24
25
On Windows LightGBM can be built using

- **Visual Studio**;

26
- **CMake** and **VS Build Tools**;
27
28

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

30
31
Visual Studio (or VS Build Tools)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32
33
34
35

With GUI
********

36
1. Install `Visual Studio`_ (2015 or newer).
37
38
39
40
41

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

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

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

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

46
The ``.exe`` file will be in ``LightGBM-master/windows/x64/Release`` folder.
47
48
49
50

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

51
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).
52
53
54
55
56

2. Run the following commands:

   .. code::

57
     git clone --recursive https://github.com/microsoft/LightGBM
58
59
60
     cd LightGBM
     mkdir build
     cd build
61
     cmake -A x64 ..
62
63
     cmake --build . --target ALL_BUILD --config Release

64
The ``.exe`` and ``.dll`` files will be in ``LightGBM/Release`` folder.
65

66
67
MinGW-w64
^^^^^^^^^
68
69
70
71
72
73
74

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

2. Run the following commands:

   .. code::

75
     git clone --recursive https://github.com/microsoft/LightGBM
76
77
78
79
80
81
     cd LightGBM
     mkdir build
     cd build
     cmake -G "MinGW Makefiles" ..
     mingw32-make.exe -j4

82
The ``.exe`` and ``.dll`` files will be in ``LightGBM/`` folder.
83

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

86
87
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>`__).
88
89

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

91
92
93
Linux
~~~~~

94
On Linux LightGBM can be built using **CMake** and **gcc** or **Clang**.
95

96
1. Install `CMake`_.
97

98
99
100
101
2. Run the following commands:

   .. code::

102
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
103
104
105
     mkdir build ; cd build
     cmake ..
     make -j4
106
107
108

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

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

111
112
macOS
~~~~~
113

114
On macOS LightGBM can be installed using **Homebrew**, or can be built using **CMake** and **Apple Clang** or **gcc**.
115
116
117

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

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

121
122
123
124
125
126
127
128
129
130
Install Using ``Homebrew``
**************************

.. code::

  brew install lightgbm

Build from GitHub
*****************

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

133
   .. code::
Nikita Titov's avatar
Nikita Titov committed
134

135
     brew install cmake
fanliwen's avatar
fanliwen committed
136

137
2. Install **OpenMP**:
fanliwen's avatar
fanliwen committed
138
139
140
141

   .. code::

     brew install libomp
142
143
144
145
146

3. Run the following commands:

   .. code::

147
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
fanliwen's avatar
fanliwen committed
148
     mkdir build ; cd build
149
150
151
152
153
154
155
156
157
158
159

     # 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
160
     cmake ..
161

fanliwen's avatar
fanliwen committed
162
163
     make -j4

164
165
gcc
^^^
166

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

169
   .. code::
170

171
     brew install cmake
172

173
2. Install **gcc**:
174

175
   .. code::
176

177
178
179
180
181
182
     brew install gcc

3. Run the following commands:

   .. code::

183
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
184
185
186
187
     export CXX=g++-7 CC=gcc-7  # replace "7" with version of gcc installed on your machine
     mkdir build ; cd build
     cmake ..
     make -j4
188

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

191
192
193
Docker
~~~~~~

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

196
197
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
229
230
231
232
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.

233
The ``.exe`` file will be in ``LightGBM-master/windows/x64/Release`` folder.
234
235
236
237
238
239
240
241
242
243

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

244
     git clone --recursive https://github.com/microsoft/LightGBM
245
246
247
     cd LightGBM
     mkdir build
     cd build
248
     cmake -A x64 -DUSE_OPENMP=OFF ..
249
250
     cmake --build . --target ALL_BUILD --config Release

251
The ``.exe`` and ``.dll`` files will be in ``LightGBM/Release`` folder.
252
253
254
255
256
257
258
259
260
261

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

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

2. Run the following commands:

   .. code::

262
     git clone --recursive https://github.com/microsoft/LightGBM
263
264
265
266
267
268
     cd LightGBM
     mkdir build
     cd build
     cmake -G "MinGW Makefiles" -DUSE_OPENMP=OFF ..
     mingw32-make.exe -j4

269
The ``.exe`` and ``.dll`` files will be in ``LightGBM/`` folder.
270
271
272
273
274
275
276
277
278
279
280
281
282
283

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

284
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
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
     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::

311
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
     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::

335
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
336
337
338
339
340
     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

341
342
343
Build MPI Version
~~~~~~~~~~~~~~~~~

344
345
The default build version of LightGBM is based on socket. LightGBM also supports MPI.
`MPI`_ is a high performance communication approach with `RDMA`_ support.
346
347
348
349
350
351

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

Windows
^^^^^^^

352
353
354
355
On Windows MPI version of LightGBM can be built using

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

356
- **MS MPI**, **CMake** and **VS Build Tools**.
357

358
359
360
With GUI
********

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

363
2. Install `Visual Studio`_ (2015 or newer).
364
365
366
367
368

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

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

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

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

373
The ``.exe`` file will be in ``LightGBM-master/windows/x64/Release_mpi`` folder.
374
375
376
377

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

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

380
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).
381
382
383
384
385

3. Run the following commands:

   .. code::

386
     git clone --recursive https://github.com/microsoft/LightGBM
387
388
389
     cd LightGBM
     mkdir build
     cd build
390
     cmake -A x64 -DUSE_MPI=ON ..
391
392
     cmake --build . --target ALL_BUILD --config Release

393
The ``.exe`` and ``.dll`` files will be in ``LightGBM/Release`` folder.
394

395
**Note**: Building MPI version by **MinGW** is not supported due to the miss of MPI library in it.
396
397
398
399

Linux
^^^^^

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

402
1. Install `Open MPI`_.
403

404
2. Install `CMake`_.
405

406
407
408
409
3. Run the following commands:

   .. code::

410
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
411
412
413
     mkdir build ; cd build
     cmake -DUSE_MPI=ON ..
     make -j4
414
415
416

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

417
418
macOS
^^^^^
419

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

422
423
Apple Clang
***********
424

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

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

429
   .. code::
430

431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
     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::

449
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
450
     mkdir build ; cd build
451
452
453
454
455
456
457
458
459
460
461
462

     # 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)
463
     cmake -DUSE_MPI=ON ..
464

465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
     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::

492
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
493
494
495
496
     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
497
498
499
500
501
502
503

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

Linux
^^^^^

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

506
507
The following dependencies should be installed before compilation:

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

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

512
-  **libboost** 1.56 or later (1.61 or later is recommended).
513
514
515
516
517

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

518
-  **CMake** 3.2 or later.
519
520
521
522
523

To build LightGBM GPU version, run the following commands:

.. code::

524
  git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
525
526
  mkdir build ; cd build
  cmake -DUSE_GPU=1 ..
527
528
  # 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/ ..
529
530
531
532
533
  make -j4

Windows
^^^^^^^

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

536
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.
537

538
539
Following procedure is for the **MSVC** (Microsoft Visual C++) build.

540
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).
541
542
543
544
545

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

546
   - For running on AMD, get AMD APP SDK.
547
548
549

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

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

Nikita Titov's avatar
Nikita Titov committed
552
3. Install `Boost Binaries`_.
553

554
   **Note**: Match your Visual C++ version:
555
556
557
   
   Visual Studio 2015 -> ``msvc-14.0-64.exe``,

558
559
560
   Visual Studio 2017 -> ``msvc-14.1-64.exe``,

   Visual Studio 2019 -> ``msvc-14.2-64.exe``.
561
562
563
564
565

4. Run the following commands:

   .. code::

566
     git clone --recursive https://github.com/microsoft/LightGBM
567
568
569
     cd LightGBM
     mkdir build
     cd build
570
571
572
     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" ..
573
574
     cmake --build . --target ALL_BUILD --config Release

575
   **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).
576
577
578
579

Docker
^^^^^^

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

582
583
584
Build HDFS Version
~~~~~~~~~~~~~~~~~~

585
HDFS version of LightGBM was tested on CDH-5.14.4 cluster.
586
587
588
589

Linux
^^^^^

590
On Linux HDFS version of LightGBM can be built using **CMake** and **gcc**.
591

592
1. Install `CMake`_.
fanliwen's avatar
fanliwen committed
593
594
595
596
597

2. Run the following commands:

   .. code::

598
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
fanliwen's avatar
fanliwen committed
599
600
     mkdir build ; cd build
     cmake -DUSE_HDFS=ON ..
601
602
603
604
605
606
     # 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
607
608
     make -j4

609
610
611
Build Java Wrapper
~~~~~~~~~~~~~~~~~~

612
613
614
615
616
By the following instructions you can generate a JAR file containing the LightGBM `C API <./Development-Guide.rst#c-api>`__ wrapped by **SWIG**.

Windows
^^^^^^^

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

619
620
VS Build Tools
**************
621

622
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).
623
624
625
626
627
628
629

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

3. Run the following commands:

   .. code::

630
     git clone --recursive https://github.com/microsoft/LightGBM
631
632
633
     cd LightGBM
     mkdir build
     cd build
634
     cmake -A x64 -DUSE_SWIG=ON ..
635
636
     cmake --build . --target ALL_BUILD --config Release

637
The ``.jar`` file will be in ``LightGBM/build`` folder and the ``.dll`` files will be in ``LightGBM/Release`` folder.
638
639
640
641
642
643
644
645
646
647
648
649

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

650
     git clone --recursive https://github.com/microsoft/LightGBM
651
652
653
654
655
656
     cd LightGBM
     mkdir build
     cd build
     cmake -G "MinGW Makefiles" -DUSE_SWIG=ON ..
     mingw32-make.exe -j4

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

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

661
662
663
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>`__).

664
665
666

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

667
668
669
Linux
^^^^^

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

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

674
2. Run the following commands:
675

676
677
   .. code::

678
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
679
680
     mkdir build ; cd build
     cmake -DUSE_SWIG=ON ..
681
     make -j4
682

683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
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::

712
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
     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::

750
     git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
751
752
753
754
755
756
757
758
     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>`__.


759
760
761
.. |download artifacts| image:: ./_static/images/artifacts-not-available.svg
   :target: https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html

762
.. _Python-package: https://github.com/microsoft/LightGBM/tree/master/python-package
763

764
.. _R-package: https://github.com/microsoft/LightGBM/tree/master/R-package
765

766
.. _zip archive: https://github.com/microsoft/LightGBM/archive/master.zip
767

768
.. _Visual Studio: https://visualstudio.microsoft.com/downloads/
769
770
771
772
773

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

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

774
.. _VS Build Tools: https://visualstudio.microsoft.com/downloads/
775
776
777
778
779
780
781

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

782
.. _MS MPI: https://www.microsoft.com/en-us/download/details.aspx?id=57467
783
784
785
786
787
788
789

.. _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
790
.. _Boost Binaries: https://bintray.com/boostorg/release/boost-binaries/_latestVersion#files
791
792

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