diff --git a/L/LightGBM/build_tarballs.jl b/L/LightGBM/build_tarballs.jl index f29e7d1f8b5..1215bef0935 100644 --- a/L/LightGBM/build_tarballs.jl +++ b/L/LightGBM/build_tarballs.jl @@ -1,13 +1,18 @@ # Note that this script can accept some limited command-line arguments, run # `julia build_tarballs.jl --help` to see a usage message. using BinaryBuilder, Pkg +using Base.BinaryPlatforms: arch, tags name = "LightGBM" -version = v"3.3.5" +version = v"4.3.0" + +const YGGDRASIL_DIR = "../.." +include(joinpath(YGGDRASIL_DIR, "fancy_toys.jl")) +include(joinpath(YGGDRASIL_DIR, "platforms", "cuda.jl")) # Collection of sources required to complete build sources = [ - GitSource("https://github.com/microsoft/LightGBM.git", "ca035b2ee0c2be85832435917b1e0c8301d2e0e0"), + GitSource("https://github.com/microsoft/LightGBM.git", "252828fd86627d7405021c3377534d6a8239dd69"), DirectorySource("./bundled"), ] @@ -17,27 +22,42 @@ cd $WORKSPACE/srcdir/LightGBM git submodule update --init --depth=1 git submodule update --checkout --depth=1 - -if [[ $target == *"apple-darwin"* ]]; then - cmake_extra_args="-DAPPLE=1 -DAPPLE_OUTPUT_DYLIB=1" -fi +# https://github.com/microsoft/LightGBM/pull/6457 +atomic_patch -p1 "$WORKSPACE/srcdir/patches/lightgbm-cmake-find-cuda.patch" FLAGS=() +cmake_extra_args=() + +if [[ "${bb_full_target}" == *"apple-darwin"* ]]; then + cmake_extra_args+=(-DAPPLE=1 -DAPPLE_OUTPUT_DYLIB=1) +fi -if [[ "${target}" == *-mingw* ]]; then - # Parches windows - for p in $WORKSPACE/srcdir/patches/windows/*.patch; do - atomic_patch -p1 "${p}" - done - cmake_extra_args="-DWIN32=1 -DMINGW=1" +if [[ "${bb_full_target}" == *-mingw* ]]; then + cmake_extra_args+=(-DWIN32=1 -DMINGW=1) FLAGS+=(LDFLAGS="-no-undefined") fi -cmake \ +if [[ "${bb_full_target}" == *-linux* ]]; then + cmake_extra_args+=(-DUSE_GPU=1) +fi + +if [[ ("${bb_full_target}" == *-cuda*) && ("${bb_full_target}" != *-cuda+none*) ]]; then + # nvcc writes to /tmp, which is a small tmpfs in our sandbox. + # make it use the workspace instead + export TMPDIR=${WORKSPACE}/tmpdir + mkdir ${TMPDIR} + export CUDA_PATH=${WORKSPACE}/destdir/cuda + export PATH=$PATH:$CUDA_PATH/bin/ + + cmake_extra_args+=(-DUSE_CUDA=1 -DCMAKE_CUDA_FLAGS="-L${CUDA_PATH}/lib -L${CUDA_PATH}/lib/stubs") +fi + +cmake . \ -DCMAKE_INSTALL_PREFIX=$prefix\ -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \ -DCMAKE_BUILD_TYPE=Release \ - $cmake_extra_args + "${cmake_extra_args[@]}" + make -j${nproc} "${FLAGS[@]}" make install install_license LICENSE @@ -46,6 +66,10 @@ install_license LICENSE # These are the platforms we will build for by default, unless further # platforms are passed in on the command line platforms = expand_cxxstring_abis(supported_platforms()) +cuda_platforms = expand_cxxstring_abis(CUDA.supported_platforms(; min_version=v"11")) + +# CUDA errors for other platforms +filter!(p -> (Sys.islinux(p) && arch(p) == "x86_64"), cuda_platforms) # The products that we will ensure are always built products = [ @@ -53,13 +77,32 @@ products = [ ExecutableProduct("lightgbm", :lightgbm), ] +all_platforms = [platforms; cuda_platforms] + # Dependencies that must be installed before this package can be built dependencies = [ # For OpenMP we use libomp from `LLVMOpenMP_jll` where we use LLVM as compiler (BSD # systems), and libgomp from `CompilerSupportLibraries_jll` everywhere else. - Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae"); platforms=filter(!Sys.isbsd, platforms)), - Dependency(PackageSpec(name="LLVMOpenMP_jll", uuid="1d63c593-3942-5779-bab2-d838dc0a180e"); platforms=filter(Sys.isbsd, platforms)), + Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae"); platforms=filter(!Sys.isbsd, all_platforms)), + Dependency(PackageSpec(name="LLVMOpenMP_jll", uuid="1d63c593-3942-5779-bab2-d838dc0a180e"); platforms=filter(Sys.isbsd, all_platforms)), + + # GPU support is enabled via OpenCL and is hard to cross compile for other platforms + Dependency(PackageSpec(name="OpenCL_jll", uuid="6cb37087-e8b6-5417-8430-1f242f1e46e4"); platforms=filter(Sys.islinux, all_platforms)), + BuildDependency(PackageSpec(name="OpenCL_Headers_jll", uuid="a7aa756b-2b7f-562a-9e9d-e94076c5c8ee"); platforms=filter(Sys.islinux, all_platforms)), + + Dependency(PackageSpec(name="boost_jll", uuid="28df3c45-c428-5900-9ff8-a3135698ca75"); compat="=1.76.0", platforms=filter(Sys.islinux, all_platforms)), ] -# Build the tarballs, and possibly a `build.jl` as well. -build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version = v"8.1.0") +for platform in all_platforms + if platform in platforms && CUDA.is_supported(platform) + platform["cuda"] = "none" + end + + deps = [dependencies; CUDA.required_dependencies(platform; static_sdk=true)] + + should_build_platform(triplet(platform)) || continue + + # Build the tarballs, and possibly a `build.jl` as well. + build_tarballs(ARGS, name, version, sources, script, [platform], products, deps; + julia_compat="1.6", preferred_gcc_version = v"8.1", augment_platform_block=CUDA.augment) +end diff --git a/L/LightGBM/bundled/patches/lightgbm-cmake-find-cuda.patch b/L/LightGBM/bundled/patches/lightgbm-cmake-find-cuda.patch new file mode 100644 index 00000000000..55406fadb5f --- /dev/null +++ b/L/LightGBM/bundled/patches/lightgbm-cmake-find-cuda.patch @@ -0,0 +1,72 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1ff289b9..e71d5b99 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -198,32 +198,28 @@ if(__INTEGRATE_OPENCL) + endif() + + if(USE_CUDA) +- find_package(CUDA 11.0 REQUIRED) +- include_directories(${CUDA_INCLUDE_DIRS}) ++ find_package(CUDAToolkit 11.0 REQUIRED) ++ include_directories(${CUDAToolkit_INCLUDE_DIRS}) + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=${OpenMP_CXX_FLAGS} -Xcompiler=-fPIC -Xcompiler=-Wall") + + # reference for mapping of CUDA toolkit component versions to supported architectures ("compute capabilities"): + # https://en.wikipedia.org/wiki/CUDA#GPUs_supported +- set(CUDA_ARCHS "6.0" "6.1" "6.2" "7.0" "7.5") +- if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") +- list(APPEND CUDA_ARCHS "8.0") ++ set(CUDA_ARCHS "60" "61" "62" "70" "75") ++ if(CUDA_VERSION VERSION_GREATER_EQUAL "110") ++ list(APPEND CUDA_ARCHS "80") + endif() +- if(CUDA_VERSION VERSION_GREATER_EQUAL "11.1") +- list(APPEND CUDA_ARCHS "8.6") ++ if(CUDA_VERSION VERSION_GREATER_EQUAL "111") ++ list(APPEND CUDA_ARCHS "86") + endif() +- if(CUDA_VERSION VERSION_GREATER_EQUAL "11.5") +- list(APPEND CUDA_ARCHS "8.7") ++ if(CUDA_VERSION VERSION_GREATER_EQUAL "115") ++ list(APPEND CUDA_ARCHS "87") + endif() +- if(CUDA_VERSION VERSION_GREATER_EQUAL "11.8") +- list(APPEND CUDA_ARCHS "8.9") +- list(APPEND CUDA_ARCHS "9.0") ++ if(CUDA_VERSION VERSION_GREATER_EQUAL "118") ++ list(APPEND CUDA_ARCHS "89") ++ list(APPEND CUDA_ARCHS "90") + endif() + list(POP_BACK CUDA_ARCHS CUDA_LAST_SUPPORTED_ARCH) + list(APPEND CUDA_ARCHS "${CUDA_LAST_SUPPORTED_ARCH}+PTX") +- cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS ${CUDA_ARCHS}) +- string(REPLACE ";" " " CUDA_ARCH_FLAGS "${CUDA_ARCH_FLAGS}") +- +- set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} ${CUDA_ARCH_FLAGS}") + if(USE_DEBUG) + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -g") + else() +@@ -260,7 +256,7 @@ if(USE_CUDA) + function(add_histogram hsize hname hadd hconst hdir) + add_library(histo${hsize}${hname} OBJECT src/treelearner/kernels/histogram${hsize}.cu) + set_target_properties(histo${hsize}${hname} PROPERTIES CUDA_SEPARABLE_COMPILATION ON) +- set_target_properties(histo${hsize}${hname} PROPERTIES CUDA_ARCHITECTURES OFF) ++ set_target_properties(histo${hsize}${hname} PROPERTIES CUDA_ARCHITECTURES ${CUDA_ARCHS}) + if(hadd) + list(APPEND histograms histo${hsize}${hname}) + set(histograms ${histograms} PARENT_SCOPE) +@@ -600,10 +596,10 @@ if(USE_CUDA) + # Disable cmake warning about policy CMP0104. Refer to issue #3754 and PR #4268. + # Custom target properties does not propagate, thus we need to specify for + # each target that contains or depends on cuda source. +- set_target_properties(lightgbm_objs PROPERTIES CUDA_ARCHITECTURES OFF) +- set_target_properties(_lightgbm PROPERTIES CUDA_ARCHITECTURES OFF) ++ set_target_properties(lightgbm_objs PROPERTIES CUDA_ARCHITECTURES ${CUDA_ARCHS}) ++ set_target_properties(_lightgbm PROPERTIES CUDA_ARCHITECTURES ${CUDA_ARCHS}) + if(BUILD_CLI) +- set_target_properties(lightgbm PROPERTIES CUDA_ARCHITECTURES OFF) ++ set_target_properties(lightgbm PROPERTIES CUDA_ARCHITECTURES ${CUDA_ARCHS}) + endif() + + set_target_properties(lightgbm_objs PROPERTIES CUDA_SEPARABLE_COMPILATION ON) diff --git a/L/LightGBM/bundled/patches/windows/Ws2_32-iphlpapi.patch b/L/LightGBM/bundled/patches/windows/Ws2_32-iphlpapi.patch deleted file mode 100644 index 77057ca8154..00000000000 --- a/L/LightGBM/bundled/patches/windows/Ws2_32-iphlpapi.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 95610d55..9d272e38 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -490,10 +490,10 @@ endif(USE_HDFS) - - if(WIN32) - if(MINGW OR CYGWIN) -- TARGET_LINK_LIBRARIES(lightgbm Ws2_32) -- TARGET_LINK_LIBRARIES(_lightgbm Ws2_32) -- TARGET_LINK_LIBRARIES(lightgbm IPHLPAPI) -- TARGET_LINK_LIBRARIES(_lightgbm IPHLPAPI) -+ TARGET_LINK_LIBRARIES(lightgbm ws2_32) -+ TARGET_LINK_LIBRARIES(_lightgbm ws2_32) -+ TARGET_LINK_LIBRARIES(lightgbm iphlpapi) -+ TARGET_LINK_LIBRARIES(_lightgbm iphlpapi) - endif(MINGW OR CYGWIN) - endif(WIN32)