3

I often run LGBM on Google Colabratory and I just found out this page saying that LGBM it set to CPU by default so you need to set up first. https://medium.com/@am.sharma/lgbm-on-colab-with-gpu-c1c09e83f2af So I executed the code recommended on the page or some other codes recommended on stackoverflow as follows, !git clone --recursive https://github.com/Microsoft/LightGBM %cd LightGBM !mkdir build %cd build !cmake ../../LightGBM !make -j4 !git clone --recursive https://github.com/Microsoft/LightGBM.git %cd LightGBM/python-package !python3 setup.py install --gpu !pip install cmake

But I still get an Error GPU Tree Learner was not enabled in this build.Please recompile with CMake option -DUSE_GPU=1

How can I fix it? Thank you!

2

1 Answer 1

7

After running

! git clone --recursive https://github.com/Microsoft/LightGBM

You can run this oneliner which will build and compile LightGBM with GPU enabled in colab:

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

Hope that helps ;D

4
  • 3
    Doesn't work. Colab says it's not utilizing GPU. Commented Jun 15, 2021 at 4:37
  • @user8491363, it worked for me, did you pass device_type='gpu' to the LGBM model?
    – YugoAmaryl
    Commented Dec 4, 2021 at 2:44
  • This worked for me (16th Mar 2023). Be aware Colab caches packages, so you may have to restart the runtime to make sure the newly-installed lightgbm is being imported, and not the old one. Commented Mar 16, 2023 at 16:18
  • For me the installation always ends with FileNotFoundError: [Errno 2] No such file or directory: '/content/LightGBM/python-package/lightgbm/VERSION.txt'
    – Nick
    Commented Jun 4, 2023 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.