Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LightGBMError: GPU Tree Learner was not enabled in this build (ubuntu 18.04 - anaconda - jupyter notebook env) #3310

Closed
diego-florez opened this issue Aug 15, 2020 · 13 comments

Comments

@diego-florez
Copy link

How you are using LightGBM?

LightGBM component: python-api -- sklear-api -- lightgbm.LGBMClassifier

Environment info

ubuntu 18.04 -- anaconda3 -- python3.7 -- jupyter notebook

Operating System: Ubuntu 18.04

CPU/GPU model: NVIDIA-SMI 390.138

C++ compiler version: gcc version 7.5.0

CMake version: cmake version 3.10.2

Python version: Python 3.7.4

LightGBM version or commit hash: LightGBM 3.0.0

Error message and / or logs

LightGBMError: GPU Tree Learner was not enabled in this build. Please recompile with CMake option -DUSE_GPU=1

I want to use LightGBM classifier with gpu on jupyter notebook and I didn't find a way to do it
I know there is a closed issue#2222 solving the problem for windows env. I have followed it as well as followed the installation guide https://lightgbm.readthedocs.io/en/latest/GPU-Tutorial.html, however I was unable to solve the problem

@StrikerRUS
Copy link
Collaborator

@diego-florez

I have followed it as well as followed the installation guide https://lightgbm.readthedocs.io/en/latest/GPU-Tutorial.html, ...

Have you tried this installation guide?
https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html#id17

however I was unable to solve the problem

Please be more precise. What is the problem? What steps did you do? Post your commands and corresponding logs.

@diego-florez
Copy link
Author

Hi @StrikerRUS

  • problem:
    LightGBMError: GPU Tree Learner was not enabled in this build. Please recompile with CMake option -DUSE_GPU=1

  • steps:
    picture bellow
    image
    Then on the jupyter nb I set the model params like this --> clf = RandomizedSearchCV(lgb.LGBMClassifier(max_depth=-1, random_state=None, silent=True, n_estimators=200 , device="gpu", gpu_platform_id = 0, gpu_device_id = 0)

@StrikerRUS
Copy link
Collaborator

OK. Seems that you have successfully compiled dynamic library. Now you should install Python wrapper.

pip uninstall lightgbm  # remove old installation that have no GPU support
cd ../python-package
python setup.py install --precompile

Please pay attention to the second line: fatal: ... It is possible that you are compiling some old version of the library. Remove LightGBM folder before git clone command.

@diego-florez
Copy link
Author

diego-florez commented Aug 25, 2020

Thanks, I solved the problem following your instructions, but now I have a problem with bin size --> LightGBMError: bin size 369 cannot run on GPU
I tried in params --> clf = RandomizedSearchCV(lgb.LGBMClassifier(max_depth=-1, random_state=None, silent=True, n_estimators=200, max_bin = 63, device="gpu", gpu_platform_id = 0, gpu_device_id = 0)

However I have the same error

Should I open another issue? As issue #3310 is solved

@guolinke
Copy link
Collaborator

@diego-florez did you use categorical features? if yes, you can try to disable them.

@diego-florez
Copy link
Author

@guolinke yes, 11/18 are categorical, but they are set as type "categorical" and I tried with the following params categorical_feature="auto" (as it is recommended), categorical_feature=my_list_of_cat_vars (as it is recommended), ignore_column=my_list_of_cat_vars (as you have said -- not sure at all if this is the param you meant)

And the same error persist with the 3 of them

@StrikerRUS
Copy link
Collaborator

@diego-florez Are you loading your data from a file? Because ignore_column parameter only works in that case:

Note: works only in case of loading data directly from file
https://lightgbm.readthedocs.io/en/latest/Parameters.html#ignore_column

@diego-florez
Copy link
Author

the training data is a pandas dataframe previously loaded in the notebook, there is not any other solution for the problem? Maybe change categorical variables to one hot encoding?

@guolinke
Copy link
Collaborator

@diego-florez can you try to use label encoding for categorical features, and don't set 'categorical_feature'. Then LightGBM will treat them as numerical features.

@naveen-marthala
Copy link

naveen-marthala commented Sep 13, 2020

OK. Seems that you have successfully compiled dynamic library. Now you should install Python wrapper.

pip uninstall lightgbm  # remove old installation that have no GPU support
cd ../python-package
python setup.py install --precompile

Please pay attention to the second line: fatal: ... It is possible that you are compiling some old version of the library. Remove LightGBM folder before git clone command.

I have done exactly what was shown in the post you replied to, in this reply.
And also did what you wrote in this reply. I can now use lighgbm with gpu.

The issue is that there's no increase in the computation speed. and the GPU is barley being used(I see usage as low as 0.08GB). How do I speed up the training? my data set sizes are, train=(247570, 70) and validation=(13031, 70). here is all my code and my hyperparameters:

from lightgbm import LGBMClassifier

lgb_test_on_gpu = LGBMClassifier(learning_rate=0.01, n_estimators=10_000, num_leaves=127, n_jobs=-1,
                                 device = 'gpu', gpu_platform_id = 0, gpu_device_id = 0,
                                 colsample_bytree=0.75, subsample=0.75, subsample_freq=5, random_state=1, objective='multi_logloss')
lgb_test_on_gpu.fit(X=strat_train_df.drop(columns='damage_grade', axis=1), y=strat_train_df.loc[:,'damage_grade'],
                    eval_set=[(strat_valid_df.drop(columns='damage_grade', axis=1), strat_valid_df.loc[:,'damage_grade'])],
                    verbose=100, early_stopping_rounds=1_000)

@StrikerRUS
Copy link
Collaborator

@naveen-9697 Please refer to #768 and some benchmarks in https://github.com/Laurae2/ml-perf/issues and https://github.com/szilard/GBM-perf/issues for the problem of small GPU utilization.

@StrikerRUS
Copy link
Collaborator

Closing this issue because the original problem has been solved.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants