From 1d4d34563435740227c4151d10092253d9282316 Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Thu, 24 Jun 2021 16:33:57 +0800 Subject: [PATCH 1/2] Tests for dask skl categorical data support. (#7054) --- python-package/xgboost/sklearn.py | 6 ++++ tests/python-gpu/test_gpu_with_dask.py | 42 +++++++++++++++++--------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/python-package/xgboost/sklearn.py b/python-package/xgboost/sklearn.py index d9b928551c48..76e5d7e9c735 100644 --- a/python-package/xgboost/sklearn.py +++ b/python-package/xgboost/sklearn.py @@ -632,6 +632,12 @@ def _configure_fit( eval_metric = None else: params.update({"eval_metric": eval_metric}) + if self.enable_categorical and params.get("tree_method", None) != "gpu_hist": + raise ValueError( + "Experimental support for categorical data is not implemented for" + " current tree method yet." + ) + return model, feval, params def _set_evaluation_result(self, evals_result: TrainingCallback.EvalsLog) -> None: diff --git a/tests/python-gpu/test_gpu_with_dask.py b/tests/python-gpu/test_gpu_with_dask.py index a08f99079c62..54087b85d1e9 100644 --- a/tests/python-gpu/test_gpu_with_dask.py +++ b/tests/python-gpu/test_gpu_with_dask.py @@ -211,20 +211,34 @@ def test_categorical(local_cuda_cluster: LocalCUDACluster) -> None: ) assert tm.non_increasing(by_builtin_results["Train"]["rmse"]) - model = output["booster"] - with tempfile.TemporaryDirectory() as tempdir: - path = os.path.join(tempdir, "model.json") - model.save_model(path) - with open(path, "r") as fd: - categorical = json.load(fd) - - categories_sizes = np.array( - categorical["learner"]["gradient_booster"]["model"]["trees"][-1][ - "categories_sizes" - ] - ) - assert categories_sizes.shape[0] != 0 - np.testing.assert_allclose(categories_sizes, 1) + def check_model_output(model: dxgb.Booster) -> None: + with tempfile.TemporaryDirectory() as tempdir: + path = os.path.join(tempdir, "model.json") + model.save_model(path) + with open(path, "r") as fd: + categorical = json.load(fd) + + categories_sizes = np.array( + categorical["learner"]["gradient_booster"]["model"]["trees"][-1][ + "categories_sizes" + ] + ) + assert categories_sizes.shape[0] != 0 + np.testing.assert_allclose(categories_sizes, 1) + + check_model_output(output["booster"]) + reg = dxgb.DaskXGBRegressor( + enable_categorical=True, n_estimators=10, tree_method="gpu_hist" + ) + reg.fit(X, y) + + check_model_output(reg.get_booster()) + + reg = dxgb.DaskXGBRegressor( + enable_categorical=True, n_estimators=10 + ) + with pytest.raises(ValueError): + reg.fit(X, y) def to_cp(x: Any, DMatrixT: Type) -> Any: From b2d300e727b36143a437a328034e1f020dd53e64 Mon Sep 17 00:00:00 2001 From: Philip Hyunsu Cho Date: Thu, 24 Jun 2021 18:07:24 -0700 Subject: [PATCH 2/2] [CI] Upgrade to CMake 3.14 (#7060) * [CI] Upgrade to CMake 3.14 * Add FATAL_ERROR directive, for users with CMake 2.x --- CMakeLists.txt | 2 +- tests/ci_build/Dockerfile.clang_tidy | 4 ++-- tests/ci_build/Dockerfile.cpu | 4 ++-- tests/ci_build/Dockerfile.gpu_build | 4 ++-- tests/ci_build/Dockerfile.gpu_build_centos6 | 4 ++-- tests/ci_build/Dockerfile.gpu_build_r_centos6 | 4 ++-- tests/ci_build/Dockerfile.jvm | 4 ++-- tests/ci_build/Dockerfile.jvm_gpu_build | 4 ++-- tests/ci_build/Dockerfile.rmm | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52fd37cd7883..3f9a80bc463a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(xgboost LANGUAGES CXX C VERSION 1.5.0) include(cmake/Utils.cmake) list(APPEND CMAKE_MODULE_PATH "${xgboost_SOURCE_DIR}/cmake/modules") diff --git a/tests/ci_build/Dockerfile.clang_tidy b/tests/ci_build/Dockerfile.clang_tidy index 661e9b925a18..a0c3339f2ebf 100644 --- a/tests/ci_build/Dockerfile.clang_tidy +++ b/tests/ci_build/Dockerfile.clang_tidy @@ -14,8 +14,8 @@ RUN \ add-apt-repository -u 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' && \ apt-get update && \ apt-get install -y llvm-10 clang-tidy-10 clang-10 && \ - wget -nv -nc https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.sh --no-check-certificate && \ - bash cmake-3.13.0-Linux-x86_64.sh --skip-license --prefix=/usr + wget -nv -nc https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.sh --no-check-certificate && \ + bash cmake-3.14.0-Linux-x86_64.sh --skip-license --prefix=/usr # Set default clang-tidy version RUN \ diff --git a/tests/ci_build/Dockerfile.cpu b/tests/ci_build/Dockerfile.cpu index bcdf99981b0f..411319b26fcd 100644 --- a/tests/ci_build/Dockerfile.cpu +++ b/tests/ci_build/Dockerfile.cpu @@ -9,8 +9,8 @@ RUN \ apt-get update && \ apt-get install -y tar unzip wget git build-essential doxygen graphviz llvm libasan2 libidn11 liblz4-dev ninja-build && \ # CMake - wget -nv -nc https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.sh --no-check-certificate && \ - bash cmake-3.13.0-Linux-x86_64.sh --skip-license --prefix=/usr && \ + wget -nv -nc https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.sh --no-check-certificate && \ + bash cmake-3.14.0-Linux-x86_64.sh --skip-license --prefix=/usr && \ # Python wget -O Miniconda3.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ bash Miniconda3.sh -b -p /opt/python diff --git a/tests/ci_build/Dockerfile.gpu_build b/tests/ci_build/Dockerfile.gpu_build index 7affdb9ed542..15b5675aa1ad 100644 --- a/tests/ci_build/Dockerfile.gpu_build +++ b/tests/ci_build/Dockerfile.gpu_build @@ -11,8 +11,8 @@ RUN \ apt-get update && \ apt-get install -y tar unzip wget bzip2 libgomp1 git build-essential doxygen graphviz llvm libasan2 libidn11 liblz4-dev ninja-build && \ # CMake - wget -nv -nc https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.sh --no-check-certificate && \ - bash cmake-3.13.0-Linux-x86_64.sh --skip-license --prefix=/usr && \ + wget -nv -nc https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.sh --no-check-certificate && \ + bash cmake-3.14.0-Linux-x86_64.sh --skip-license --prefix=/usr && \ # Python wget -O Miniconda3.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ bash Miniconda3.sh -b -p /opt/python diff --git a/tests/ci_build/Dockerfile.gpu_build_centos6 b/tests/ci_build/Dockerfile.gpu_build_centos6 index 0f23cddf98c9..5ac473cc8acb 100644 --- a/tests/ci_build/Dockerfile.gpu_build_centos6 +++ b/tests/ci_build/Dockerfile.gpu_build_centos6 @@ -23,8 +23,8 @@ RUN \ bash Miniconda3.sh -b -p /opt/python && \ /opt/python/bin/python -m pip install auditwheel && \ # CMake - wget -nv -nc https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.sh --no-check-certificate && \ - bash cmake-3.13.0-Linux-x86_64.sh --skip-license --prefix=/usr && \ + wget -nv -nc https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.sh --no-check-certificate && \ + bash cmake-3.14.0-Linux-x86_64.sh --skip-license --prefix=/usr && \ # Ninja mkdir -p /usr/local && \ cd /usr/local/ && \ diff --git a/tests/ci_build/Dockerfile.gpu_build_r_centos6 b/tests/ci_build/Dockerfile.gpu_build_r_centos6 index fd9f2d5ef3d6..d78664717ae8 100644 --- a/tests/ci_build/Dockerfile.gpu_build_r_centos6 +++ b/tests/ci_build/Dockerfile.gpu_build_r_centos6 @@ -86,8 +86,8 @@ RUN \ bash Miniconda3.sh -b -p /opt/python && \ /opt/python/bin/python -m pip install auditwheel && \ # CMake - wget -nv -nc https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.sh --no-check-certificate && \ - bash cmake-3.13.0-Linux-x86_64.sh --skip-license --prefix=/usr && \ + wget -nv -nc https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.sh --no-check-certificate && \ + bash cmake-3.14.0-Linux-x86_64.sh --skip-license --prefix=/usr && \ # Ninja mkdir -p /usr/local && \ cd /usr/local/ && \ diff --git a/tests/ci_build/Dockerfile.jvm b/tests/ci_build/Dockerfile.jvm index c73de17b2148..aa4cf2262577 100644 --- a/tests/ci_build/Dockerfile.jvm +++ b/tests/ci_build/Dockerfile.jvm @@ -18,8 +18,8 @@ RUN \ wget -O Miniconda3.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ bash Miniconda3.sh -b -p /opt/python && \ # CMake - wget -nv -nc https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.sh --no-check-certificate && \ - bash cmake-3.13.0-Linux-x86_64.sh --skip-license --prefix=/usr && \ + wget -nv -nc https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.sh --no-check-certificate && \ + bash cmake-3.14.0-Linux-x86_64.sh --skip-license --prefix=/usr && \ # Maven wget https://archive.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz && \ tar xvf apache-maven-3.6.1-bin.tar.gz -C /opt && \ diff --git a/tests/ci_build/Dockerfile.jvm_gpu_build b/tests/ci_build/Dockerfile.jvm_gpu_build index 9a488b8164d6..afbfd9c79e5a 100644 --- a/tests/ci_build/Dockerfile.jvm_gpu_build +++ b/tests/ci_build/Dockerfile.jvm_gpu_build @@ -22,8 +22,8 @@ RUN \ wget -O Miniconda3.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ bash Miniconda3.sh -b -p /opt/python && \ # CMake - wget -nv -nc https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.sh --no-check-certificate && \ - bash cmake-3.13.0-Linux-x86_64.sh --skip-license --prefix=/usr && \ + wget -nv -nc https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.sh --no-check-certificate && \ + bash cmake-3.14.0-Linux-x86_64.sh --skip-license --prefix=/usr && \ # Maven wget https://archive.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz && \ tar xvf apache-maven-3.6.1-bin.tar.gz -C /opt && \ diff --git a/tests/ci_build/Dockerfile.rmm b/tests/ci_build/Dockerfile.rmm index a7e00f9c1262..65ec7266fbfa 100644 --- a/tests/ci_build/Dockerfile.rmm +++ b/tests/ci_build/Dockerfile.rmm @@ -14,8 +14,8 @@ RUN \ wget -O Miniconda3.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ bash Miniconda3.sh -b -p /opt/python && \ # CMake - wget -nv -nc https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.sh --no-check-certificate && \ - bash cmake-3.13.0-Linux-x86_64.sh --skip-license --prefix=/usr + wget -nv -nc https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.sh --no-check-certificate && \ + bash cmake-3.14.0-Linux-x86_64.sh --skip-license --prefix=/usr # NCCL2 (License: https://docs.nvidia.com/deeplearning/sdk/nccl-sla/index.html) RUN \