目錄
官方教程:https://github.com/Microsoft/LightGBM/blob/master/docs/Installation-Guide.rst#macos
1、mac安裝lightgbm之兩步走策略(要求編譯器:Apple Clang version 8.1 or higher)
(1)安裝homebrew
參考:https://brew.sh/index_zh-cn
(官方源太慢,有時會出現問題,可參考本人另一個博客第9點:https://www.cnblogs.com/hugechuanqi/p/12604123.html)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
(2)使用homebrew直接安裝
brew install lightgbm
2、mac安裝lightgbm之三步走戰略(通過gcc構建)
(1)安裝homebrew
參考:https://brew.sh/index_zh-cn
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
(2)安裝cmake和gcc
brew install cmake
brew install gcc
(3)使用gcc構建:mac上gcc可能為8.1版本,我們需要將編譯器改為gcc-7版本
git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
export CXX=g++-7 CC=gcc-7 # replace "7" with version of gcc installed on your machine
mkdir build ; cd build
cmake ..
make -j4
3、mac安裝lightgbm之四步走戰略:不考慮gcc
(1)安裝homebrew
參考:https://brew.sh/index_zh-cn
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
(2)安裝cmake和OpenMP
brew install cmake
(3)安裝OpenMP
brew install libomp
(4)直接使用cmake構建makefile,然后make編譯
git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
mkdir build ; cd build
cmake ..
make -j4
4、python中運行lightgbm
參考:https://github.com/microsoft/LightGBM/tree/master/python-package
如果要在python中運行lightgbm,除了上面的三種方法之一外,還需要:
brew install libomp
python -m pip install lightgbm