-
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
[R-package] Add GPU install options (fixes #3765) #3779
Conversation
@jameslamb Please note this my comment in #3765
So I believe it worth to run tests without
before merging this PR. Could you please do this as I guess you already have easy access to the environment you've described in your starting comment? |
I just tried this, and compilation failed
|
OK, expected. Please try passing |
Building like this, with Rscript build_r.R \
--use-gpu \
--opencl-library=/usr/local/cuda/lib64/libOpenCL.so \
--opencl-include-dir=/usr/local/cuda/include/ full DockerfileFROM nvidia/cuda:10.2-devel-ubuntu18.04
ENV DEBIAN_FRONTEND="noninteractive"
RUN apt-get update && \
apt-get install \
-y \
software-properties-common \
apt-transport-https
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 && \
add-apt-repository 'deb [arch=amd64] https://cran.rstudio.com/bin/linux/ubuntu bionic-cran40/' && \
apt-get update && \
apt-get install -y \
r-base
RUN apt-get install -y \
git \
wget \
libcurl4-openssl-dev \
default-jdk-headless \
libssl-dev \
libxml2-dev \
cmake
ENV MAKE="make -j$(nproc)"
RUN R -e 'install.packages(c("R6","data.table","jsonlite"), repos = "https://cran.rstudio.com/")'
RUN apt-get install -y \
libboost-dev \
libboost-system-dev \
libboost-filesystem-dev \
clinfo
RUN mkdir -p /etc/OpenCL/vendors && \
echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd ## otherwise lightgm segfaults at runtime (compiles fine without it)
COPY LightGBM /tmp/LightGBM
RUN cd /tmp/LightGBM && \
git submodule init && \
git submodule update --recursive && \
Rscript build_r.R \
--use-gpu \
--opencl-library=/usr/local/cuda/lib64/libOpenCL.so \
--opencl-include-dir=/usr/local/cuda/include/
Build Logs (click me)
I ran the testing code but with
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except one typo! But I haven't dug deep into R code.
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
I think that since we have so many CI jobs for
|
This pull request 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. |
This PR offers a fix for #3765. In that issue, @szilard described some issues using CMake-based builds of the LightGBM R package with GPU support. Specifically, compilation failed because LightGBM couldn't find OpenCL and Boost.
Changes in this PR
This PR adds the following command-line options to
build_r.R
--boost-root
--boost-dir
--boost-include-dir
--boost-librarydir
--opencl-include-dir
--opencl-library
The approach it takes is similar to how the Python package handles these same arguments:
LightGBM/python-package/setup.py
Lines 131 to 144 in 706f2af
How I tested this
I adopted @szilard 's reproducible example from #3765
Dockerfile
with the following content. The laptop I do GPU development on has CUDA 10.2 installed so I chose a CUDA 10.2 image, but I expect this would work for other versions.Dockerfile (click me)
docker build --no-cache -t test-lgb-gpu -f Dockerfile .
nvidia-smi
.test R script (click me)
Based on the output of
nvidia-smi
, I'm fairly sure that training is actually taking advantage of the GPU.Notes for Reviewers
I'll add an issue and update here.[R-package] Add an R GPU job in CI #3780build_r.R
. I think this will make this more stable, even if it means users need to do a little bit more configuration. Let me know if you disagree with this.