0

I use command like below to re-install gpu version of lightgbm in colab pro+:

! cd LightGBM && rm -rf build && mkdir build && cd build && cmake -DUSE_GPU=1  ../../LightGBM && make -j8 && cd ../python-package && python3 setup.py install --precompile --gpu;

and when i use gpu to train, they give me error message: LightGBMError: No OpenCL device found

and I also tried this:
cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda/targets/x86_64-linux/lib/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/ ../../LightGBM && make -j8 && cd ../python-package && python3 setup.py install --precompile --gpu;

the lib also give me the same error massage: LightGBMError: No OpenCL device found

How can I solve this problem? Thank you!

Jiehunt
  • 41
  • 3

1 Answers1

0

I was stuck with a very similar issue. I found a workaround for myself which seemed to work. It appears that OpenCL drivers for NVIDIA are not present by default. Since Colab runs on Ubuntu instance, the following worked for me. Let's begin:

  • Step 1: Uninstall the existing lightgbm package and restart the runtime. Remember to select GPU in HW accelerator settings.
  • Step2: Executing the following commands in given sequence and restart the runtime:
!sudo apt install nvidia-driver-460 nvidia-cuda-toolkit clinfo
!apt-get update --fix-missing
  • Step 3: Now we will install lighgbm with GPU:
!pip install lightgbm --install-option=--gpu --install-option="--opencl-include-dir=/usr/local/cuda/include/" --install-option="--opencl-library=/usr/local/cuda/lib64/libOpenCL.so"
  • Step 4: Now restart the run time and check by running the below three blocks of code. Each is to be executed in the sequence mentioned and in different cells:

Taken from https://stackoverflow.com/a/60361970/5908127

from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
import lightgbm as lgbm
X,y = make_classification(n_samples=8000000, n_features=100, n_classes=2)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)
%%timeit
model = lgbm.LGBMClassifier(device="gpu")
model.fit(X_train, y_train)
%%timeit
model = lgbm.LGBMClassifier(device="cpu")
model.fit(X_train, y_train)

That's it! :D

AAM
  • 19
  • 7