-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
How to setup LightGBM with GPU support in a specific Conda environment for Python? #5989
Comments
Thanks for using LightGBM. As far as I know, the
(we don't maintain that package, though) You can conda create \
-c conda-forge \
--name lgb-gpu \
python=3.10 \
numpy \
scipy
source activate lgb-gpu
pip install lightgbm On macOS, or if you're on an older Linux distribution that doesn't support at least GLIBC 2.28, you could run the following (as documented at https://github.com/microsoft/LightGBM/blob/master/python-package/README.rst#install-from-pypi). # (optionally) get Boost if you don't have it
conda install --yes -c conda-forge boost
# compile the GPU version of LightGBM from sources on PyPI
pip install \
--no-binary lightgbm \
--config-settings=cmake.define.USE_GPU=ON \
lightgbm Once you've installed import lightgbm as lgb
from sklearn.datasets import make_regression
X, y = make_regression(n_samples=10_000)
dtrain = lgb.Dataset(X, label=y, params={"device": "gpu"})
bst = lgb.train(
train_set=dtrain,
params={
"device_type": "gpu",
"objective": "rmse",
"verbosity": 1
}
) For completeness... also note the LightGBM ships with two different build types for GPU acceleration. The one I described above is based on OpenCL... it's not limited to NVIDIA GPUs, and has been in LightGBM for several years. There's also a newer CUDA-based build, which you can use to target NVIDIA GPUs if you have CUDA 11.0 or newer available. As of # compile the GPU version of LightGBM from sources on PyPI
pip install \
--no-binary lightgbm \
--config-settings=cmake.define.USE_CUDA=ON \
lightgbm And you can then use it by passing the following in {"device_type": "cuda"} |
Also, I see that you double-posted this here and on stack overflow: https://stackoverflow.com/questions/76713117/how-to-set-up-lightgbm-with-gpu-in-a-specific-conda-environment-for-python. Please don't do that. I could have been spending time answering this while someone else was spending time answering you on Stack Overflow. That would be a waste of the limited time and effort of the LightGBM community, and makes it harder for search engines to decide which conversation to direct people with the same question to. |
Hi @jameslamb, Thank you very much for answer. I will try it tomorrow morning and let you know about the results. Also, thank you very much for last point. I will take this into account. Thanks. |
Hi @jameslamb, I have tried the solution you have provided. I uninstalled the boost and lightgbm packages and installed them with the following code: # (optionally) get Boost if you don't have it
conda install --yes -c conda-forge boost
# compile the GPU version of LightGBM from sources on PyPI
pip install \
--no-binary lightgbm \
--config-settings=cmake.define.USE_GPU=ON \
lightgbm However, I received the following error: [LightGBM] [Fatal] GPU Tree Learner was not enabled in this build.
Please recompile with CMake option -DUSE_GPU=1 Then, I tried the following: # compile the GPU version of LightGBM from sources on PyPI
pip install \
--no-binary lightgbm \
--config-settings=cmake.define.USE_GPU=ON \
lightgbm However, it also did not work. How should I proceed? |
Don't know if it will help you but I was having problems building cuda version until I switched gcc (and g++ for good measure) to version 10 for compiling. Lead came from this reference: NVIDIA/nccl#650 |
can not build with cuda Building wheels for collected packages: lightgbm × Building wheel for lightgbm (pyproject.toml) did not run successfully.
note: This error originates from a subprocess, and is likely not a problem with pip. |
I solved the problem with the following way.
|
@jameslamb Would it be possible for you to either ask for ownership of the the feedstock or to submit a PR to that repo which allows for a Using |
While am trying this am getting an error like does not appear to contain CMakeLists.txt. |
@enesgencer18 could you please let me know whether you have created any CMakeLists.txt? |
It's finally possible now! 🎉 Default version supports training with OpenCL-based acceleration |
Summary
I would like to setup LightGBM with GPU support in a specific Conda environment for Python. How can I do that?
Thanks,
The text was updated successfully, but these errors were encountered: