mac安装lightgbm之两步走战略

官方教程: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

posted @ 2020-03-31 11:44  hugechuanqi  阅读(2049)  评论(0编辑  收藏  举报