From 8721c8b570cbf04f09358d02e96d1a96e9f30467 Mon Sep 17 00:00:00 2001 From: hcho3 Date: Fri, 12 Apr 2024 20:02:57 +0000 Subject: [PATCH 1/6] [CI] Update RAPIDS to latest stable --- tests/buildkite/conftest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/buildkite/conftest.sh b/tests/buildkite/conftest.sh index 0d051001f2d3..44043910bc96 100755 --- a/tests/buildkite/conftest.sh +++ b/tests/buildkite/conftest.sh @@ -24,7 +24,7 @@ set -x CUDA_VERSION=11.8.0 NCCL_VERSION=2.16.5-1 -RAPIDS_VERSION=24.02 +RAPIDS_VERSION=24.04 SPARK_VERSION=3.4.0 JDK_VERSION=8 R_VERSION=4.3.2 From fbc8511685e46f20044fb6cd8d74f396a0efd0c8 Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Fri, 12 Apr 2024 15:13:29 -0700 Subject: [PATCH 2/6] [CI] Use rapidsai stable channel; fix syntax errors in Dockerfile.gpu --- tests/ci_build/Dockerfile.gpu | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ci_build/Dockerfile.gpu b/tests/ci_build/Dockerfile.gpu index 698a61e93eb2..255dd9d71874 100644 --- a/tests/ci_build/Dockerfile.gpu +++ b/tests/ci_build/Dockerfile.gpu @@ -21,14 +21,14 @@ ENV PATH=/opt/mambaforge/bin:$PATH # Create new Conda environment with cuDF, Dask, and cuPy RUN \ - conda install -c conda-forge mamba && \ - mamba create -n gpu_test -c rapidsai-nightly -c rapidsai -c nvidia -c conda-forge -c defaults \ + export NCCL_SHORT_VER=$(echo "$NCCL_VERSION_ARG" | cut -d "-" -f 1) && \ + mamba create -y -n gpu_test -c rapidsai -c nvidia -c conda-forge \ python=3.10 cudf=$RAPIDS_VERSION_ARG* rmm=$RAPIDS_VERSION_ARG* cudatoolkit=$CUDA_VERSION_ARG \ - nccl>=$(cut -d "-" -f 1 << $NCCL_VERSION_ARG) \ + "nccl>=${NCCL_SHORT_VER}" \ dask=2024.1.1 \ dask-cuda=$RAPIDS_VERSION_ARG* dask-cudf=$RAPIDS_VERSION_ARG* cupy \ numpy pytest pytest-timeout scipy scikit-learn pandas matplotlib wheel python-kubernetes urllib3 graphviz hypothesis \ - pyspark>=3.4.0 cloudpickle cuda-python && \ + "pyspark>=3.4.0" cloudpickle cuda-python && \ mamba clean --all && \ conda run --no-capture-output -n gpu_test pip install buildkite-test-collector From acf3482c58e60a54065894eb604c4a31c341475b Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Fri, 12 Apr 2024 15:32:09 -0700 Subject: [PATCH 3/6] Don't combine astype() with loc() --- python-package/xgboost/testing/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python-package/xgboost/testing/__init__.py b/python-package/xgboost/testing/__init__.py index 409fd0274eeb..f7d9510faea6 100644 --- a/python-package/xgboost/testing/__init__.py +++ b/python-package/xgboost/testing/__init__.py @@ -429,8 +429,8 @@ def make_categorical( categories = np.arange(0, n_categories) for col in df.columns: if rng.binomial(1, cat_ratio, size=1)[0] == 1: - df.loc[:, col] = df[col].astype("category") - df.loc[:, col] = df[col].cat.set_categories(categories) + df[col] = df[col].astype("category") + df[col] = df[col].cat.set_categories(categories) if sparsity > 0.0: for i in range(n_features): From 2674b67ac5181a88d622fd2d917354e556777848 Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Sat, 13 Apr 2024 06:12:28 +0000 Subject: [PATCH 4/6] Work around https://github.com/dmlc/xgboost/issues/10181 --- python-package/xgboost/data.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python-package/xgboost/data.py b/python-package/xgboost/data.py index 07a08dc5f0b2..4a5956b8334f 100644 --- a/python-package/xgboost/data.py +++ b/python-package/xgboost/data.py @@ -909,9 +909,16 @@ def _transform_cudf_df( enable_categorical: bool, ) -> Tuple[ctypes.c_void_p, list, Optional[FeatureNames], Optional[FeatureTypes]]: try: - from cudf.api.types import is_categorical_dtype + from cudf.api.types import is_categorical_dtype, is_bool_dtype except ImportError: from cudf.utils.dtypes import is_categorical_dtype + from pandas.api.types import is_bool_dtype + + # Work around https://github.com/dmlc/xgboost/issues/10181 + if _is_cudf_ser(data) and is_bool_dtype(data.dtype): + data = data.astype(np.uint8) + else: + data = data.astype({col: np.uint8 for col in data.select_dtypes(include="bool")}) if _is_cudf_ser(data): dtypes = [data.dtype] From 7e1d1a9c09d5b0f2e702a58bdd696815ddc23b7a Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Sat, 13 Apr 2024 20:32:05 +0000 Subject: [PATCH 5/6] Fix formatting --- python-package/xgboost/data.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python-package/xgboost/data.py b/python-package/xgboost/data.py index 4a5956b8334f..03d42c8428dc 100644 --- a/python-package/xgboost/data.py +++ b/python-package/xgboost/data.py @@ -909,7 +909,7 @@ def _transform_cudf_df( enable_categorical: bool, ) -> Tuple[ctypes.c_void_p, list, Optional[FeatureNames], Optional[FeatureTypes]]: try: - from cudf.api.types import is_categorical_dtype, is_bool_dtype + from cudf.api.types import is_bool_dtype, is_categorical_dtype except ImportError: from cudf.utils.dtypes import is_categorical_dtype from pandas.api.types import is_bool_dtype @@ -918,7 +918,9 @@ def _transform_cudf_df( if _is_cudf_ser(data) and is_bool_dtype(data.dtype): data = data.astype(np.uint8) else: - data = data.astype({col: np.uint8 for col in data.select_dtypes(include="bool")}) + data = data.astype( + {col: np.uint8 for col in data.select_dtypes(include="bool")} + ) if _is_cudf_ser(data): dtypes = [data.dtype] From fc127452451ac98145bac0222ce4f7a1c9f4e74e Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Sat, 13 Apr 2024 20:39:53 +0000 Subject: [PATCH 6/6] Fix test --- python-package/xgboost/data.py | 5 +++-- tests/python-gpu/test_from_cudf.py | 9 --------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/python-package/xgboost/data.py b/python-package/xgboost/data.py index 03d42c8428dc..12b5765664be 100644 --- a/python-package/xgboost/data.py +++ b/python-package/xgboost/data.py @@ -915,8 +915,9 @@ def _transform_cudf_df( from pandas.api.types import is_bool_dtype # Work around https://github.com/dmlc/xgboost/issues/10181 - if _is_cudf_ser(data) and is_bool_dtype(data.dtype): - data = data.astype(np.uint8) + if _is_cudf_ser(data): + if is_bool_dtype(data.dtype): + data = data.astype(np.uint8) else: data = data.astype( {col: np.uint8 for col in data.select_dtypes(include="bool")} diff --git a/tests/python-gpu/test_from_cudf.py b/tests/python-gpu/test_from_cudf.py index 8707af0c885f..c3a0b7d5faac 100644 --- a/tests/python-gpu/test_from_cudf.py +++ b/tests/python-gpu/test_from_cudf.py @@ -71,15 +71,6 @@ def _test_from_cudf(DMatrixT): assert dtrain.num_col() == 1 assert dtrain.num_row() == 5 - # Boolean is not supported. - X_boolean = cudf.DataFrame({"x": cudf.Series([True, False])}) - with pytest.raises(Exception): - dtrain = DMatrixT(X_boolean) - - y_boolean = cudf.DataFrame({"x": cudf.Series([True, False, True, True, True])}) - with pytest.raises(Exception): - dtrain = DMatrixT(X_boolean, label=y_boolean) - def _test_cudf_training(DMatrixT): import pandas as pd