Contents

install lightGBM-GPU on Ubuntu

1. libs

1
2
3
apt update && apt install -y cmake ocl-icd-opencl-dev libboost-all-dev
export LIBOPENCL=/usr/local/nvidia/lib64
mkdir -p /etc/OpenCL/vendors && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd

2. repo

1
2
3
4
5
6
7
8
9
git clone --recursive https://github.com/Microsoft/LightGBM 
cd LightGBM && mkdir build && cd build
cmake -DUSE_GPU=1 ..
make -j4
pip uninstall lightgbm
cd .. ; bash ./build-python.sh install --gpu

# if has issues on "import lightgbm as lgbm"
conda install -c conda-forge libstdcxx-ng=12

3. test

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11

m sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
import lightgbm as lgbm

X,y = make_classification(n_samples=2000000, n_features=100, n_classes=2)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)

model = lgbm.LGBMClassifier(device="gpu")  # 5.3s
#model = lgbm.LGBMClassifier()  # 9.83s, 10CPU cores
model.fit(X_train, y_train)