Google Compute EngineにLightGBMをインストールする


はじめに

Google Compute EngineにLightGBMをインストールする手順を記載します.

環境

Python version: Python 3.6.5 :: Anaconda custom (64-bit)
OS: CentOS Linux release 7.5.1804 (Core)

インストール

Open MPIのインストール

Lightgbmのビルドには分散処理を可能にするBuild MPI Version が存在する.
これを利用するため,まずOpen MPIをインストールする.

cd /usr/local
curl -O https://download.open-mpi.org/release/open-mpi/v3.1/openmpi-3.1.0.tar.gz
tar xvf openmpi-3.1.0.tar.gz
cd openmpi-3.1.0
./configure --prefix=/usr/local/openmpi-3.1.0  CC=gcc CXX=g++
make -j 4 all 2>&1 | tee make.log
make -j 4 install 2>&1 | tee install.log

PATHを通す.

~/.bash_profile
MPIROOT=/usr/local/openmpi-3.0.1
export PATH=$MPIROOT/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MPIROOT/lib
export MANPATH=$MANPATH:$MPIROOT/share/man

適用

source ~/.bash_profile

LightGBMのインストール

前述した通り,MPI versionでのビルドを行う.

sudo yum install cmake
git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
mkdir build ; cd build
cmake -DUSE_MPI=ON ..
make -j4

python-packageのセットアップ

cd LightGBM/python-package
python setup.py install

これでpythonからLightGBMを使用可能になる.

import lightgbm