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

[R-package] Add GPU support for CRAN package #3206

Closed
jameslamb opened this issue Jul 4, 2020 · 7 comments
Closed

[R-package] Add GPU support for CRAN package #3206

jameslamb opened this issue Jul 4, 2020 · 7 comments

Comments

@jameslamb
Copy link
Collaborator

jameslamb commented Jul 4, 2020

Summary

#3188 added an installation strategy for the R package that is compliant with CRAN's restrictions. I originally added support for using a flag to build a GPU-enabled version from that CRAN package, but decided to pull it out of that pull request. I think it deserves more careful thought and testing.

Description

The goal of this issue is to be able to build the CRAN package for the GPU, like this:

sh build-cran-package.sh
R CMD INSTALL \
    --configure-args='--enable-gpu' \
    lightgbm_2.3.2.tar.gz

The following code was removed from that PR, and adding it back would be a good start:

R-package/README.md
#### Custom Installation (Linux, Mac)

You can use `-configure-args to build a GPU-enabled version of the package.

Rscript build_r.R --skip-install
R CMD INSTALL \
    --configure-args='--enable-gpu' \
    lightgbm_2.3.2.tar.gz

#### Custom Installation (Windows)

Since R on Windows does not support the use of `--configure-args`, building a GPU-enabled version of the package on Windows requires the use of an environment variable.

To install from source with GPU on Windows, set environment variable `LGB_USE_GPU` to `true`.

setx LGB_USE_GPU "true"

Restart CMD, then check that it was set:

echo %LGB_USE_GPU%

If it shows `true`, you should see the flag `-DUSE_GPU` in the compiler messages.

R CMD install lightgbm_*.tar.gz
R-package/configure.ac
# Compile for GPU?
AC_ARG_ENABLE(
    [gpu],
    AS_HELP_STRING(
        [--enable-gpu],
        [Pass this flag to install the R package for usage with GPU]
    ),
    [
        LGB_CPPFLAGS+=" -DUSE_GPU"
    ]
)
configure.win
# Compile for GPU?
# Check whether environment variable LGB_USE_GPU has been set to true
if test ${LGB_USE_GPU};
then
    if ${LGB_USE_GPU} = "true";
    then
        LGB_CPPFLAGS="${LGB_CPPFLAGS} -DUSE_GPU"
    fi
fi
@jameslamb
Copy link
Collaborator Author

This has been added to #2302 . Leave a comment here or on that issue if you'd like to contribute this feature!

@StrikerRUS
Copy link
Collaborator

I wonder, how will it be useful for users given that they have to install Boost and OpenCL by their own anyway? The only difference will be "CMake vs configure", if I'm not mistaken. Maybe it's better to provide a link for the guide how build from the most recent sources?

@jameslamb
Copy link
Collaborator Author

I don't think it is something we have to do before going to CRAN, but it would be useful some day in the same way that Python users can do this

pip install lightgbm --install-option=--gpu
  • no need to have or know about cmake
  • no need to have or know about git or GitHub

I agree that it's ok to just have it documented in the README how to build for source, maybe for a long time, but I do think this could be useful one day.

@StrikerRUS
Copy link
Collaborator

@jameslamb Would it make sense to add the same feature request for CUDA build? If you are OK, I can create an issue.

@jameslamb
Copy link
Collaborator Author

yes definitely! I think @Laurae2 already did a proof of concept of "R package with CUDA", but dont remember where it was posted.

Either way yes, definitely

@StrikerRUS
Copy link
Collaborator

Created #3465.

but dont remember where it was posted.

Here it is

szilard/GBM-perf#12 (comment)

https://gist.github.com/Laurae2/7195cebe65887907a06e9118a3ec7f96

@jameslamb
Copy link
Collaborator Author

oh perfect, thank you!

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

2 participants