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

[python-package] support GPU training with the conda-forge package #5419

Closed
BinchaoPeng opened this issue Aug 12, 2022 · 11 comments
Closed

[python-package] support GPU training with the conda-forge package #5419

BinchaoPeng opened this issue Aug 12, 2022 · 11 comments

Comments

@BinchaoPeng
Copy link

Summary

I use conda install -c conda-forge lightgbm to install lightgbm, and I found it may not support gpu device.

Motivation

Installing gpu-version lightgbm by conda command.

Description

when conda install -c conda-forge lightgbm, then

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

Therefore, is it possible to get gpu lightgbm with conda install?

References

[github_使用conda安装](https://github.com/Microsoft/LightGBM/tree/master/python-package#install-from-conda-forge-channel)

@BinchaoPeng
Copy link
Author

I think the simplest way to use lightgbm that is just use conda install lightgbm and then I can use lightgbm as like pytorch.However, it semms that lightgbm does not has the feature.

@jameslamb
Copy link
Collaborator

@BinchaoPeng thanks for using LightGBM!

The conda-forge package for lightgbm is not maintained by this project's maintainers (https://github.com/conda-forge/lightgbm-feedstock) and does not currently support GPU training.

We can take it as a feature request to try to add that support there at some point, and it might get easier in the future with the work done in #3403 and #5252 .

It looks like there is someone trying to add integrated GPU support to the lightgbmpackage on conda-forge (conda-forge/lightgbm-feedstock#40), but that PR so far hasn't received feedback from that feedstock's maintainers.

@jameslamb jameslamb changed the title LightGBMError: GPU Tree Learner was not enabled in this build. Please recompile with CMake option -DUSE_GPU=1 [python-package] support GPU training in the conda-forge package Oct 12, 2022
@jameslamb jameslamb changed the title [python-package] support GPU training in the conda-forge package [python-package] support GPU training with the conda-forge package Oct 12, 2022
@BinchaoPeng
Copy link
Author

Thank you very much!

@jameslamb
Copy link
Collaborator

Sure! I'm going to close this for now, as we keep issues for feature requests closed (and track them in #2302) in this repo until they're being actively worked on.

Thanks again for your interest in LightGBM!

@github-actions

This comment was marked as off-topic.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2023
@jameslamb
Copy link
Collaborator

Sorry, this was locked accidentally. Just unlocked it. We'd still love help with this feature!

@microsoft microsoft unlocked this conversation Aug 17, 2023
@jameslamb
Copy link
Collaborator

I think so! I'd like to test it on a system with CUDA when I have time and update LightGBM's documentation.

I think the CUDA-based version will automatically be chosen on systems with CUDA available, thanks to the __cuda metapackage from conda, and otherwise the OpenCL-based version will be installed.

@StrikerRUS
Copy link
Collaborator

I'd like to test it on a system with CUDA

Just did it:

~$ conda install lightgbm
Retrieving notices: ...working... done
Channels:
 - conda-forge
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
    current version: 24.3.0
    latest version: 24.5.0

Please update conda by running

    $ conda update -n base -c conda-forge conda



## Package Plan ##

  environment location: /opt/miniforge3/envs/myenv

  added / updated specs:
    - lightgbm


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    cudatoolkit-11.8.0         |      h4ba93d1_13       682.5 MB  conda-forge
    libgfortran-ng-14.1.0      |       h69a702a_0          49 KB  conda-forge
    libgfortran5-14.1.0        |       hc5f4f2c_0         1.4 MB  conda-forge
    libopenblas-0.3.27         |pthreads_hac2b453_1         5.3 MB  conda-forge
    libstdcxx-ng-14.1.0        |       hc0a3c3a_0         3.7 MB  conda-forge
    lightgbm-4.4.0             |cuda_py3.10hc57aca7_3         6.6 MB  conda-forge
    numpy-2.0.0                |  py310h515e003_0         7.4 MB  conda-forge
    python_abi-3.10            |          4_cp310           6 KB  conda-forge
    scipy-1.14.0               |  py310h93e2701_1        16.0 MB  conda-forge
    ------------------------------------------------------------
                                           Total:       722.9 MB

The following NEW packages will be INSTALLED:

  cudatoolkit        conda-forge/linux-64::cudatoolkit-11.8.0-h4ba93d1_13
  libblas            conda-forge/linux-64::libblas-3.9.0-22_linux64_openblas
  libcblas           conda-forge/linux-64::libcblas-3.9.0-22_linux64_openblas
  libgfortran-ng     conda-forge/linux-64::libgfortran-ng-14.1.0-h69a702a_0
  libgfortran5       conda-forge/linux-64::libgfortran5-14.1.0-hc5f4f2c_0
  liblapack          conda-forge/linux-64::liblapack-3.9.0-22_linux64_openblas
  libopenblas        conda-forge/linux-64::libopenblas-0.3.27-pthreads_hac2b453_1
  libstdcxx-ng       conda-forge/linux-64::libstdcxx-ng-14.1.0-hc0a3c3a_0
  lightgbm           conda-forge/linux-64::lightgbm-4.4.0-cuda_py3.10hc57aca7_3
  numpy              conda-forge/linux-64::numpy-2.0.0-py310h515e003_0
  python_abi         conda-forge/linux-64::python_abi-3.10-4_cp310
  scipy              conda-forge/linux-64::scipy-1.14.0-py310h93e2701_1


Proceed ([y]/n)? y


Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: \ By downloading and using the CUDA Toolkit conda packages, you accept the terms and conditions of the CUDA End User License Agreement (EULA): https://docs.nvidia.com/cuda/eula/index.html
                                                                                                                                       done

And after installation CUDA works 🎉 :

~$ python
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lightgbm as lgb
>>> import numpy as np
>>> rng = np.random.default_rng()
>>> data = rng.uniform(size=(500, 10))  # 500 entities, each contains 10 features
>>> label = rng.integers(low=0, high=2, size=(500, ))  # binary target
>>> lgb.LGBMClassifier(device='cuda').fit(data, label)
[LightGBM] [Warning] Using sparse features with CUDA is currently not supported.
[LightGBM] [Info] Number of positive: 227, number of negative: 273
[LightGBM] [Info] Total Bins 1670
[LightGBM] [Info] Number of data points in the train set: 500, number of used features: 10
[LightGBM] [Info] [binary:BoostFromScore]: pavg=0.454000 -> initscore=-0.184522
[LightGBM] [Info] Start training from score -0.184522
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 21 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 21 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 21 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 16 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 21 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 21 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 17 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 21 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 21 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 21 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 18 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 21 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 21 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 19 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 21 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
[LightGBM] [Warning] No further splits with positive gain, training stopped with 20 leaves.
LGBMClassifier(device='cuda')

Note the following line from logs: [LightGBM] [Warning] Using sparse features with CUDA is currently not supported.

@jameslamb
Copy link
Collaborator

Hey great! Ok yes I think we can consider this solved then.

For those finding this from search engines and looking for something to copy-paste:

conda install -c conda-forge 'lightgbm>=4.4.0'

I will put up some docs changes.

@BinchaoPeng
Copy link
Author

So cool, respect!🥴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants