|
| 1 | +From 7782edc8e004bd3fe10879c52753d6a6de35947d Mon Sep 17 00:00:00 2001 |
| 2 | +From: Hyunsu Cho < [email protected]> |
| 3 | +Date: Fri, 28 Jun 2024 17:38:34 -0700 |
| 4 | +Subject: [PATCH] Backport fixes |
| 5 | + |
| 6 | +* Undo dmlc/xgboost#9436 |
| 7 | +* Explicitly link with CCCL (standalone or CTK) (#10624, #10633) |
| 8 | +* Partial fix for CTK 12.5 (#10574) |
| 9 | +--- |
| 10 | + CMakeLists.txt | 27 ++++++++++++++++++--------- |
| 11 | + cmake/Utils.cmake | 7 +++---- |
| 12 | + src/tree/updater_gpu_common.cuh | 21 ++++++++------------- |
| 13 | + src/tree/updater_gpu_hist.cu | 1 + |
| 14 | + 4 files changed, 30 insertions(+), 26 deletions(-) |
| 15 | + |
| 16 | +diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 17 | +index c4ca82937..aa078405f 100644 |
| 18 | +--- a/CMakeLists.txt |
| 19 | ++++ b/CMakeLists.txt |
| 20 | +@@ -224,6 +224,24 @@ if(USE_CUDA) |
| 21 | + add_subdirectory(${PROJECT_SOURCE_DIR}/gputreeshap) |
| 22 | + |
| 23 | + find_package(CUDAToolkit REQUIRED) |
| 24 | ++ find_package(CCCL CONFIG) |
| 25 | ++ if(NOT CCCL_FOUND) |
| 26 | ++ message(STATUS "Standalone CCCL not found. Attempting to use CCCL from CUDA Toolkit...") |
| 27 | ++ find_package(CCCL CONFIG |
| 28 | ++ HINTS ${CUDAToolkit_LIBRARY_DIR}/cmake) |
| 29 | ++ if(NOT CCCL_FOUND) |
| 30 | ++ message(STATUS "Could not locate CCCL from CUDA Toolkit. Using Thrust and CUB from CUDA Toolkit...") |
| 31 | ++ find_package(libcudacxx CONFIG REQUIRED |
| 32 | ++ HINTS ${CUDAToolkit_LIBRARY_DIR}/cmake) |
| 33 | ++ find_package(CUB CONFIG REQUIRED |
| 34 | ++ HINTS ${CUDAToolkit_LIBRARY_DIR}/cmake) |
| 35 | ++ find_package(Thrust CONFIG REQUIRED |
| 36 | ++ HINTS ${CUDAToolkit_LIBRARY_DIR}/cmake) |
| 37 | ++ thrust_create_target(Thrust HOST CPP DEVICE CUDA) |
| 38 | ++ add_library(CCCL::CCCL INTERFACE IMPORTED GLOBAL) |
| 39 | ++ target_link_libraries(CCCL::CCCL INTERFACE libcudacxx::libcudacxx CUB::CUB Thrust) |
| 40 | ++ endif() |
| 41 | ++ endif() |
| 42 | + endif() |
| 43 | + |
| 44 | + if(FORCE_COLORED_OUTPUT AND (CMAKE_GENERATOR STREQUAL "Ninja") AND |
| 45 | +@@ -301,15 +319,6 @@ add_subdirectory(${xgboost_SOURCE_DIR}/plugin) |
| 46 | + |
| 47 | + if(PLUGIN_RMM) |
| 48 | + find_package(rmm REQUIRED) |
| 49 | +- |
| 50 | +- # Patch the rmm targets so they reference the static cudart |
| 51 | +- # Remove this patch once RMM stops specifying cudart requirement |
| 52 | +- # (since RMM is a header-only library, it should not specify cudart in its CMake config) |
| 53 | +- get_target_property(rmm_link_libs rmm::rmm INTERFACE_LINK_LIBRARIES) |
| 54 | +- list(REMOVE_ITEM rmm_link_libs CUDA::cudart) |
| 55 | +- list(APPEND rmm_link_libs CUDA::cudart_static) |
| 56 | +- set_target_properties(rmm::rmm PROPERTIES INTERFACE_LINK_LIBRARIES "${rmm_link_libs}") |
| 57 | +- get_target_property(rmm_link_libs rmm::rmm INTERFACE_LINK_LIBRARIES) |
| 58 | + endif() |
| 59 | + |
| 60 | + if(PLUGIN_SYCL) |
| 61 | +diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake |
| 62 | +index d555f5edf..c1f19fdbb 100644 |
| 63 | +--- a/cmake/Utils.cmake |
| 64 | ++++ b/cmake/Utils.cmake |
| 65 | +@@ -108,12 +108,12 @@ function(xgboost_set_cuda_flags target) |
| 66 | + target_compile_definitions(${target} PRIVATE -DXGBOOST_USE_NVTX=1) |
| 67 | + endif() |
| 68 | + |
| 69 | ++ target_link_libraries(${target} |
| 70 | ++ PRIVATE CCCL::CCCL CUDA::cudart_static) |
| 71 | + target_compile_definitions(${target} PRIVATE -DXGBOOST_USE_CUDA=1) |
| 72 | + target_include_directories( |
| 73 | + ${target} PRIVATE |
| 74 | +- ${xgboost_SOURCE_DIR}/gputreeshap |
| 75 | +- ${xgboost_SOURCE_DIR}/rabit/include |
| 76 | +- ${CUDAToolkit_INCLUDE_DIRS}) |
| 77 | ++ ${xgboost_SOURCE_DIR}/gputreeshap) |
| 78 | + |
| 79 | + if(MSVC) |
| 80 | + target_compile_options(${target} PRIVATE |
| 81 | +@@ -240,7 +240,6 @@ macro(xgboost_target_link_libraries target) |
| 82 | + |
| 83 | + if(USE_CUDA) |
| 84 | + xgboost_set_cuda_flags(${target}) |
| 85 | +- target_link_libraries(${target} PUBLIC CUDA::cudart_static) |
| 86 | + endif() |
| 87 | + |
| 88 | + if(PLUGIN_RMM) |
| 89 | +diff --git a/src/tree/updater_gpu_common.cuh b/src/tree/updater_gpu_common.cuh |
| 90 | +index 1c3e6a552..5d999d6d6 100644 |
| 91 | +--- a/src/tree/updater_gpu_common.cuh |
| 92 | ++++ b/src/tree/updater_gpu_common.cuh |
| 93 | +@@ -1,18 +1,13 @@ |
| 94 | +-/*! |
| 95 | +- * Copyright 2017-2019 XGBoost contributors |
| 96 | ++/** |
| 97 | ++ * Copyright 2017-2024, XGBoost contributors |
| 98 | + */ |
| 99 | + #pragma once |
| 100 | +-#include <thrust/random.h> |
| 101 | +-#include <cstdio> |
| 102 | +-#include <cub/cub.cuh> |
| 103 | +-#include <stdexcept> |
| 104 | +-#include <string> |
| 105 | +-#include <vector> |
| 106 | +-#include "../common/categorical.h" |
| 107 | +-#include "../common/device_helpers.cuh" |
| 108 | +-#include "../common/random.h" |
| 109 | ++#include <limits> // for numeric_limits |
| 110 | ++#include <ostream> // for ostream |
| 111 | ++ |
| 112 | + #include "gpu_hist/histogram.cuh" |
| 113 | + #include "param.h" |
| 114 | ++#include "xgboost/base.h" |
| 115 | + |
| 116 | + namespace xgboost::tree { |
| 117 | + struct GPUTrainingParam { |
| 118 | +@@ -54,8 +49,8 @@ enum DefaultDirection { |
| 119 | + }; |
| 120 | + |
| 121 | + struct DeviceSplitCandidate { |
| 122 | +- float loss_chg {-FLT_MAX}; |
| 123 | +- DefaultDirection dir {kLeftDir}; |
| 124 | ++ float loss_chg{-std::numeric_limits<float>::max()}; |
| 125 | ++ DefaultDirection dir{kLeftDir}; |
| 126 | + int findex {-1}; |
| 127 | + float fvalue {0}; |
| 128 | + // categorical split, either it's the split category for OHE or the threshold for partition-based |
| 129 | +diff --git a/src/tree/updater_gpu_hist.cu b/src/tree/updater_gpu_hist.cu |
| 130 | +index 958fa0331..e126aeb31 100644 |
| 131 | +--- a/src/tree/updater_gpu_hist.cu |
| 132 | ++++ b/src/tree/updater_gpu_hist.cu |
| 133 | +@@ -19,6 +19,7 @@ |
| 134 | + #include "../common/cuda_context.cuh" // CUDAContext |
| 135 | + #include "../common/device_helpers.cuh" |
| 136 | + #include "../common/hist_util.h" |
| 137 | ++#include "../common/random.h" // for ColumnSampler, GlobalRandom |
| 138 | + #include "../common/timer.h" |
| 139 | + #include "../data/ellpack_page.cuh" |
| 140 | + #include "../data/ellpack_page.h" |
| 141 | +-- |
| 142 | +2.45.2 |
| 143 | + |
0 commit comments