Ching-Chuan Chen's Blogger

Statistics, Machine Learning and Programming

0%

Build the GPU Version of LightGBM in CentOS 7

這篇主要是紀錄如何在CentOS要怎麼去編譯GPU Version的LightGBM

其實官方安裝文件已經寫得非常清楚

但是因為Centos 7提供的boost實在太舊了,你需要自己編譯。cmake則是需要安裝cmake3,CentOS的cmake是2.8

CUDA安裝就不介紹了,從Nvidia那裡載下來rpm,然後安裝,再輸入指令yum install -y cuda即可,最後就可以在/usr/local看到你的cuda

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
yum install cmake3 opencl-headers -y
ln -s /usr/bin/cmake3 /usr/bin/cmake

wget https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz
tar -zxvf boost_1_66_0.tar.gz
cd boost_1_66_0
./bootstrap.sh --prefix=/usr --libdir=/usr/lib64
./b2 install

# 下載lightGBM,並重新命名
git clone --recursive https://github.com/Microsoft/LightGBM
mv LightGBM LightGBM-20180816
cd LightGBM-20180816

# 開始編譯
mkdir build
cd build
export OpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so
export OpenCL_INCLUDE_DIR=/usr/local/cuda-9.2/include/CL
cmake -DUSE_GPU=1 ..
make -j4

# R安裝
cd ../R-package
Rscript build_package.R
# 改成用precompiled so跟GPU
sed -i -e "s/use_precompile <.*/use_precompile <- TRUE/g" src/install.libs.R
sed -i -e "s/use_gpu <.*/use_gpu <- TRUE/g" src/install.libs.R
R CMD INSTALL . --build --no-multiarch

# python安裝
cd ../python-package
pip3.5 install setuptools numpy scikit-learn scipy
python3.5 setup.py install --precompile -O2