Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing GPU support for LightGBM on Google Collab

Anyone got luck trying to install GPU support for lightgbm on Google Collab using the Notebooks there ?

like image 639
Propanon Avatar asked Apr 02 '18 07:04

Propanon


People also ask

Can LightGBM run on GPU?

In LightGBM, the main computation cost during training is building the feature histograms. We use an efficient algorithm on GPU to accelerate this process. The implementation is highly modular, and works for all learning tasks (classification, ranking, regression, etc).

Does colab support GPU?

More technically, Colab is a hosted Jupyter notebook service that requires no setup to use, while providing access free of charge to computing resources including GPUs. Yes.

How do I use free GPU on Google Colab?

Click on “Notebook settings” and select “GPU”. That's it. You have a free 12GB NVIDIA Tesla K80 GPU to run up to 12 hours continuously for free. It is worth mentioning both Google Colab and Kaggle offer awesome GPU power.


3 Answers

Very simple: just run

!pip install lightgbm --install-option=--gpu

or

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"

Remember to enable GPU support in your notebook and add'device':'gpu' in the lightgbm setting. And don't forget to uninstall the version of lightgbm that don't support gpu version first.

like image 102
JP Zhang Avatar answered Sep 28 '22 06:09

JP Zhang


make sure you followed the installation steps correctly

!git clone --recursive https://github.com/Microsoft/LightGBM
%cd LightGBM
!mkdir build
%cd build
!cmake ../../LightGBM
!make -j4

after this you have to execute the setupfile in LightGBM folder

%cd LightGBM/python-package
!python3 setup.py install --gpu

Once thats done , you're all set. ps: make sure you have cmake installed, if not just

!pip install cmake
like image 28
zsfVishnu Avatar answered Sep 28 '22 06:09

zsfVishnu


Most of it was following the documentation provided here, with two small tweaks to make it work on Google Colab.
Since the instances are renewed after 12 hours of usage, I post this at the beginning of my notebook to reinstall GPU support with lightgbm :

    !apt-get -qq install --no-install-recommends nvidia-375
    !apt-get -qq install --no-install-recommends nvidia-opencl-icd-375 nvidia-opencl-dev opencl-headers
    !apt-get -qq install --no-install-recommends git cmake build-essential libboost-dev libboost-system-dev libboost-filesystem-dev
    !pip3 install -qq lightgbm --install-option=--gpu
like image 20
Propanon Avatar answered Sep 28 '22 06:09

Propanon