Skip to content

Commit 79353b5

Browse files
authored
b/381256047 lightgbm gpu install (#1451)
1 parent 77a3516 commit 79353b5

File tree

5 files changed

+47
-9
lines changed

5 files changed

+47
-9
lines changed

Dockerfile.tmpl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
FROM us-docker.pkg.dev/colab-images/public/runtime:latest
1+
ARG BASE_IMAGE \
2+
BASE_IMAGE_TAG \
3+
LIGHTGBM_VERSION
4+
5+
{{ if eq .Accelerator "gpu" }}
6+
FROM gcr.io/kaggle-images/python-lightgbm-whl:${BASE_IMAGE_TAG}-${LIGHTGBM_VERSION} AS lightgbm_whl
7+
{{ end }}
8+
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG}
29

310
ADD kaggle_requirements.txt /kaggle_requirements.txt
411

@@ -49,6 +56,17 @@ RUN update-alternatives --set cuda /usr/local/cuda-$CUDA_MAJOR_VERSION.$CUDA_MIN
4956

5057
RUN uv pip install --system "pycuda"
5158

59+
# b/381256047 Remove once installed in Colabs base image.
60+
# Install LightGBM
61+
COPY --from=lightgbm_whl /tmp/whl/*.whl /tmp/lightgbm/
62+
# Install OpenCL (required by LightGBM GPU version)
63+
RUN apt-get install -y ocl-icd-libopencl1 clinfo && \
64+
mkdir -p /etc/OpenCL/vendors && \
65+
echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd && \
66+
uv pip install --system /tmp/lightgbm/*.whl && \
67+
rm -rf /tmp/lightgbm && \
68+
/tmp/clean-layer.sh
69+
5270
# Remove CUDA_VERSION from non-GPU image.
5371
{{ else }}
5472
ENV CUDA_VERSION=""

Jenkinsfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,29 @@ pipeline {
2121
}
2222

2323
stages {
24+
stage('Pre-build Packages from Source') {
25+
stages {
26+
stage('lightgbm') {
27+
options {
28+
timeout(time: 10, unit: 'MINUTES')
29+
}
30+
steps {
31+
sh '''#!/bin/bash
32+
set -exo pipefail
33+
source config.txt
34+
cd packages/
35+
./build_package --base-image $BASE_IMAGE:$BASE_IMAGE_TAG \
36+
--package lightgbm \
37+
--version $LIGHTGBM_VERSION \
38+
--build-arg CUDA_MAJOR_VERSION=$CUDA_MAJOR_VERSION \
39+
--build-arg CUDA_MINOR_VERSION=$CUDA_MINOR_VERSION \
40+
--push
41+
'''
42+
}
43+
}
44+
}
45+
}
46+
2447
stage('Build/Test/Diff') {
2548
parallel {
2649
stage('CPU') {

config.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
BASE_IMAGE=us-docker.pkg.dev/colab-images/public/runtime
2+
BASE_IMAGE_TAG=release-colab_20240920-060127_RC00
3+
LIGHTGBM_VERSION=4.5.0
14
CUDA_MAJOR_VERSION=12
25
CUDA_MINOR_VERSION=2

packages/build_package

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,8 @@ if [[ -z "$DOCKERFILE" ]]; then
115115
exit 1
116116
fi
117117

118-
# Keep only `tf2-gpu.2-6:m80` in `gcr.io/deeplearning-platform-release/tf2-gpu.2-6:m80`
119-
TAG=${BASE_IMAGE/gcr.io\/deeplearning-platform-release\//}
120-
# Keep only `python:v108` in `gcr.io/kaggle-images/python:v108`
121-
TAG=${TAG/gcr.io\/kaggle-images\//}
122-
# Replace the `:` in `tf2-gpu.2-6:m80` by `-`
123-
TAG=${TAG/:/-}
118+
# Keep only `release-colab_20240920-060127_RC00` in `us-docker.pkg.dev/colab-images/public/runtime:release-colab_20240920-060127_RC00`
119+
TAG=$(echo $BASE_IMAGE | cut -d ':' -f 2)
124120
# Append the package version
125121
TAG=$TAG-$PACKAGE_VERSION
126122
# Add the gcr repo.

tests/test_lightgbm.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ def test_cpu(self):
3434

3535
self.assertEqual(1, gbm.best_iteration)
3636

37-
# TODO(b/381256047): Colab needs to install GPU-enabled lightgbm.
3837
@gpu_test
39-
@unittest.skip("Skipping this test until b/381256047 is resolved.")
4038
def test_gpu(self):
4139
lgb_train, lgb_eval = self.load_datasets()
4240

0 commit comments

Comments
 (0)