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] CUDA version not truly installing #6417

Closed
T-Flet opened this issue Apr 16, 2024 · 5 comments
Closed

[python-package] CUDA version not truly installing #6417

T-Flet opened this issue Apr 16, 2024 · 5 comments

Comments

@T-Flet
Copy link

T-Flet commented Apr 16, 2024

Description

Following the Python package CUDA Version installation instructions produces no errors, but running it with device = 'cuda' in the parameter dictionary does (at least on Windows), yielding

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

Is there a workaround?

Installation process (with no errors)

pip install lightgbm --config-settings=cmake.define.USE_CUDA=ON

(=ON or =1) while having each of the following installed:

  • CMake (3.29.2)
  • VS / VS Tools (2022)
  • CUDA Toolkit (12.4.1)
  • Either or both of the boost Python package (conda install -c conda-forge boost) and the Boost binaries (of version higher than the first supporting the C++ compiler in the installed VS) (1.84.0)

Also tried (with errors)

--no-binary

The following fails in Building wheel for lightgbm (pyproject.toml):

pip install --no-binary lightgbm --config-settings=cmake.define.USE_CUDA=1 lightgbm

Error (after very long processing, silently running the cmakes in the next attempt):

...
      *** CMake build failed
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for lightgbm
Failed to build lightgbm
ERROR: Could not build wheels for lightgbm, which is required to install pyproject.toml-based projects

(No clear cause in the endless log above this, which is the same one produced during the successful build below).

Local python-package folder install after successful build

(Trying to follow this post just in case the Python package is able to use the built version).

git clone --recursive https://github.com/microsoft/LightGBM
cd LightGBM
mkdir build
cd build
cmake -A x64 -DUSE_CUDA=1 -DBOOST_ROOT=C:/local/boost_1_84_0 -DBOOST_LIBRARYDIR=C:/local/boost_1_84_0\lib64-msvc-14.3 ..
cmake --build . --target ALL_BUILD --config Release
cd ..

After the build succeeds, try and appease

pip install -e .\python-package\ --config-settings=cmake.define.USE_CUDA=1

by copying CMakeLists.txt, LICENSE and the src folder into the python-package folder, eventually producing the same error as above.

@T-Flet T-Flet changed the title Python CUDA version not truly installing [python-package] CUDA version not truly installing Apr 16, 2024
@jameslamb
Copy link
Collaborator

Thanks for using LightGBM.

As the documentation (link) states:

Windows
The CUDA version is not supported on Windows. Use the GPU version (device_type=gpu) for GPU acceleration on Windows.

There is a very conversation about this in #6325.

If you'd like to help with getting that support added here, we'd welcome more specifics on exactly the issue you're facing. You could provide the following:

pip install \
    --no-binary lightgbm \
    --config-settings=cmake.define.USE_CUDA=ON \
    'lightgbm>=4.3.0'

into the python-package folder

Do not try to pip install python-package/, cd python-package/ && python setup.py install, or similar here. This project's source layout does not support that.

If you want to build the Python package from a cloned copy of the entire repo, do it like this:

sh build-python.sh install --cuda

@T-Flet
Copy link
Author

T-Flet commented Apr 16, 2024

Thank you for the quick reply and apologies for not linking the CLI documentation bit about CUDA support on Windows (I thought there might have been a chance for the Python package since its documentation gives the installation command shortly after mentioning the build requirement for Windows, and the GPU version installs and works fine for me).

Environment

Here are the additional environment details:

  • Python 3.11.7
  • Windows 11 Pro - 23H2 - 22631.3447

And the previous ones restated for convenience:

The CUDA Toolkit was installed with the Windows 11 x86_64 exe from the link and resides at C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4; the build command detected it on its own so I did not have to supply its path as an extra argument.

Full output of install command

pip install \
    --no-binary lightgbm \
    --config-settings=cmake.define.USE_CUDA=ON \
    'lightgbm>=4.3.0'

console_output.txt

Full output of build-python.sh

sh build-python.sh install --cuda

in the cloned repo.
console_output2.txt

@shiyu1994
Copy link
Collaborator

Thank you for reporting this. The CUDA version has not been tested on Windows yet. I can help to verify it on windows environment when I find some time.

@jameslamb
Copy link
Collaborator

@shiyu1994 I have an old Windows laptop with a GeForce, I can help test this one too. I just wanted to get the full output from this report first to be sure we understood the issue.

@StrikerRUS
Copy link
Collaborator

Closing as a duplicate of #3837.
Let's consolidate discussion of CUDA version support on Windows in that issue.

@StrikerRUS StrikerRUS closed this as not planned Won't fix, can't repro, duplicate, stale Jul 24, 2024
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

4 participants