microsoft / LightGBM

A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks.
https://lightgbm.readthedocs.io/en/latest/
MIT License
16.7k stars 3.83k forks source link

[R-package] [gpu] CMake-based build on Windows fails. #6289

Closed ruddnr closed 9 months ago

ruddnr commented 9 months ago

Hi. Thank you for maintaining this awesome package. I'm trying to build gpu version in r, but it keeps fail.

I tried with and without providing boost and opencl path but none of them succeeded.

Rscript build_r.R --use-gpu \
--opencl-library="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/OpenCL.lib" \
--opencl-include-dir="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include" \
--boost-root=C:/local/boost_1_84_0 \
--boost-librarydir=C:/local/boost_1_84_0/lib64-msvc-14.3 --no-build-vignettes --use-msys2
Rscript build_r.R --use-gpu --no-build-vignettes --use-msys2

Below is the error message.

C:\LightGBM>Rscript build_r.R --use-gpu --no-build-vignettes --use-msys2
* checking for file 'C:/LightGBM/lightgbm_r/DESCRIPTION' ... OK
* preparing 'lightgbm':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
WARNING: directory 'lightgbm/src/external_libs/compute/test' is empty
* looking to see if a 'data/datalist' file should be added
* building 'lightgbm_4.3.0.tar.gz'
Warning in utils::tar(filepath, pkgname, compression = compression, compression_level = 9L,  :
  storing paths of more than 100 bytes is not portable:
  'lightgbm/src/external_libs/compute/include/boost/compute/algorithm/detail/find_extrema_with_atomics.hpp'
Warning in utils::tar(filepath, pkgname, compression = compression, compression_level = 9L,  :
  storing paths of more than 100 bytes is not portable:
  'lightgbm/src/external_libs/compute/include/boost/compute/algorithm/detail/find_extrema_with_reduce.hpp'
Warning in utils::tar(filepath, pkgname, compression = compression, compression_level = 9L,  :
  storing paths of more than 100 bytes is not portable:
  'lightgbm/src/external_libs/compute/include/boost/compute/algorithm/detail/reduce_by_key_with_scan.hpp'
Warning in utils::tar(filepath, pkgname, compression = compression, compression_level = 9L,  :
  storing paths of more than 100 bytes is not portable:
  'lightgbm/src/external_libs/compute/include/boost/compute/iterator/detail/get_base_iterator_buffer.hpp'

* installing to library 'C:/Users/drago/AppData/Local/R/win-library/4.3'
* installing *source* package 'lightgbm' ...
** using staged installation
** libs
installing via 'install.libs.R' to C:/Users/drago/AppData/Local/R/win-library/4.3/00LOCK-lightgbm/00new/lightgbm
Trying to build with MSYS2
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/rtools43/x86_64-w64-mingw32.static.posix/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/rtools43/x86_64-w64-mingw32.static.posix/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- R version passed into FindLibR.cmake: 4.3.2
-- Found LibR: C:/Program Files/R/R-4.3.2
-- LIBR_EXECUTABLE: C:/Program Files/R/R-4.3.2/bin/x64/R.exe
-- LIBR_INCLUDE_DIRS: C:/Program Files/R/R-4.3.2/include
-- LIBR_CORE_LIBRARY: C:/Program Files/R/R-4.3.2/bin/x64/R.dll
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Looking for CL_VERSION_3_0
-- Looking for CL_VERSION_3_0 - found
-- Found OpenCL: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/OpenCL.lib (found version "3.0")
-- OpenCL include directory: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include
-- Found Boost: C:/rtools43/x86_64-w64-mingw32.static.posix/lib/cmake/Boost-1.81.0/BoostConfig.cmake (found suitable version "1.81.0", minimum required is "1.56.0") found components: filesystem system
-- Performing Test MM_PREFETCH
-- Performing Test MM_PREFETCH - Success
-- Using _mm_prefetch
-- Performing Test MM_MALLOC
-- Performing Test MM_MALLOC - Success
-- Using _mm_malloc
-- Looking for inet_pton
-- Looking for inet_pton - found
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/build
-- R version passed into FindLibR.cmake: 4.3.2
-- LIBR_EXECUTABLE: C:/Program Files/R/R-4.3.2/bin/x64/R.exe
-- LIBR_INCLUDE_DIRS: C:/Program Files/R/R-4.3.2/include
-- LIBR_CORE_LIBRARY: C:/Program Files/R/R-4.3.2/bin/x64/R.dll
-- OpenCL include directory: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include
-- Using _mm_prefetch
-- Using _mm_malloc
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/build
Building lib_lightgbm
[  2%] Building CXX object CMakeFiles/lightgbm_capi_objs.dir/src/c_api.cpp.obj
[  5%] Building CXX object CMakeFiles/lightgbm_capi_objs.dir/src/lightgbm_R.cpp.obj
[  5%] Built target lightgbm_capi_objs
[  8%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/boosting.cpp.obj
[ 11%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt.cpp.obj
[ 13%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt_model_text.cpp.obj
[ 16%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt_prediction.cpp.obj
[ 19%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/prediction_early_stop.cpp.obj
[ 22%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/sample_strategy.cpp.obj
[ 25%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/bin.cpp.obj
[ 27%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/config.cpp.obj
[ 30%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/config_auto.cpp.obj
[ 33%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/dataset.cpp.obj
[ 36%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/dataset_loader.cpp.obj
[ 38%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/file_io.cpp.obj
[ 41%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/json11.cpp.obj
[ 44%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/metadata.cpp.obj
[ 47%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/parser.cpp.obj
[ 50%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/train_share_states.cpp.obj
[ 52%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/tree.cpp.obj
[ 55%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/metric/dcg_calculator.cpp.obj
[ 58%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/metric/metric.cpp.obj
[ 61%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/network/linker_topo.cpp.obj
[ 63%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/network/linkers_mpi.cpp.obj
[ 66%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/network/linkers_socket.cpp.obj
[ 69%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/network/network.cpp.obj
[ 72%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/objective/objective_function.cpp.obj
[ 75%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/data_parallel_tree_learner.cpp.obj
In file included from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/cl.hpp:19,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/config.hpp:16,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/buffer.hpp:14,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/core.hpp:18,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/gpu_tree_learner.h:33,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/parallel_tree_learner.h:15,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/data_parallel_tree_learner.cpp:9:
C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include/CL/cl.h:26:104: note: '#pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)'
   26 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)")
      |                                                                                                        ^
[ 77%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/feature_parallel_tree_learner.cpp.obj
In file included from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/cl.hpp:19,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/config.hpp:16,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/buffer.hpp:14,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/core.hpp:18,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/gpu_tree_learner.h:33,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/parallel_tree_learner.h:15,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/feature_parallel_tree_learner.cpp:8:
C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include/CL/cl.h:26:104: note: '#pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)'
   26 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)")
      |                                                                                                        ^
[ 80%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/gpu_tree_learner.cpp.obj
In file included from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/cl.hpp:19,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/config.hpp:16,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/buffer.hpp:14,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/core.hpp:18,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/gpu_tree_learner.h:33,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/gpu_tree_learner.cpp:7:
C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include/CL/cl.h:26:104: note: '#pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)'
   26 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)")
      |                                                                                                        ^
[ 83%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/gradient_discretizer.cpp.obj
[ 86%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/linear_tree_learner.cpp.obj
[ 88%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/serial_tree_learner.cpp.obj
[ 91%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/tree_learner.cpp.obj
In file included from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/cl.hpp:19,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/config.hpp:16,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/buffer.hpp:14,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/core.hpp:18,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/gpu_tree_learner.h:33,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/tree_learner.cpp:7:
C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include/CL/cl.h:26:104: note: '#pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)'
   26 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)")
      |                                                                                                        ^
[ 94%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/voting_parallel_tree_learner.cpp.obj
In file included from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/cl.hpp:19,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/config.hpp:16,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/buffer.hpp:14,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/external_libs/compute/include/boost/compute/core.hpp:18,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/gpu_tree_learner.h:33,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/parallel_tree_learner.h:15,
                 from C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/src/treelearner/voting_parallel_tree_learner.cpp:11:
C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include/CL/cl.h:26:104: note: '#pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)'
   26 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)")
      |                                                                                                        ^
[ 97%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/utils/openmp_wrapper.cpp.obj
[ 97%] Built target lightgbm_objs
[100%] Linking CXX shared library /C/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/lib_lightgbm.dll
C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: internal error: aborting at ../../binutils-2.40/ld/ldlang.c:527 in compare_section
C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: please report this bug
collect2.exe: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/_lightgbm.dir/build.make:159: C:/Users/drago/AppData/Local/Temp/RtmpqAUAyd/R.INSTALL15ce4d557c12/lightgbm/src/lib_lightgbm.dll] Error 1
Error in .run_shell_command(build_cmd, build_args) :
  Command failed with exit code: 2
make[2]: *** [CMakeFiles/Makefile2:140: CMakeFiles/_lightgbm.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:147: CMakeFiles/_lightgbm.dir/rule] Error 2
make: *** [Makefile:195: _lightgbm] Error 2
* removing 'C:/Users/drago/AppData/Local/R/win-library/4.3/lightgbm'
Error in .run_shell_command(install_cmd, install_args) :
  Command failed with exit code: 1
Execution halted

If I delete --use-msys2 then I get the error message below.

C:\LightGBM>Rscript build_r.R --use-gpu --no-build-vignettes
* checking for file 'C:/LightGBM/lightgbm_r/DESCRIPTION' ... OK
* preparing 'lightgbm':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
WARNING: directory 'lightgbm/src/external_libs/compute/test' is empty
* looking to see if a 'data/datalist' file should be added
* building 'lightgbm_4.3.0.tar.gz'
Warning in utils::tar(filepath, pkgname, compression = compression, compression_level = 9L,  :
  storing paths of more than 100 bytes is not portable:
  'lightgbm/src/external_libs/compute/include/boost/compute/algorithm/detail/find_extrema_with_atomics.hpp'
Warning in utils::tar(filepath, pkgname, compression = compression, compression_level = 9L,  :
  storing paths of more than 100 bytes is not portable:
  'lightgbm/src/external_libs/compute/include/boost/compute/algorithm/detail/find_extrema_with_reduce.hpp'
Warning in utils::tar(filepath, pkgname, compression = compression, compression_level = 9L,  :
  storing paths of more than 100 bytes is not portable:
  'lightgbm/src/external_libs/compute/include/boost/compute/algorithm/detail/reduce_by_key_with_scan.hpp'
Warning in utils::tar(filepath, pkgname, compression = compression, compression_level = 9L,  :
  storing paths of more than 100 bytes is not portable:
  'lightgbm/src/external_libs/compute/include/boost/compute/iterator/detail/get_base_iterator_buffer.hpp'

* installing to library 'C:/Users/drago/AppData/Local/R/win-library/4.3'
* installing *source* package 'lightgbm' ...
** using staged installation
** libs
installing via 'install.libs.R' to C:/Users/drago/AppData/Local/R/win-library/4.3/00LOCK-lightgbm/00new/lightgbm
Trying 'Visual Studio 17 2022'
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 6.2.9200.
-- The C compiler identification is MSVC 19.38.33133.0
-- The CXX compiler identification is MSVC 19.38.33133.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- R version passed into FindLibR.cmake: 4.3.2
-- Creating R.lib and R.def
Creating 'C:/Users/drago/AppData/Local/Temp/Rtmps5d31u/R.INSTALL15c843984516f/lightgbm/src/build/R.def' from 'C:/Program Files/R/R-4.3.2/bin/x64/R.dll'
Successfully created 'C:/Users/drago/AppData/Local/Temp/Rtmps5d31u/R.INSTALL15c843984516f/lightgbm/src/build/R.def'
Successfully created build files for 'Visual Studio 17 2022'
-- Found LibR: C:/Program Files/R/R-4.3.2
-- LIBR_EXECUTABLE: C:/Program Files/R/R-4.3.2/bin/x64/R.exe
-- LIBR_INCLUDE_DIRS: C:/Program Files/R/R-4.3.2/include
-- LIBR_CORE_LIBRARY: C:/Program Files/R/R-4.3.2/bin/x64/R.dll
-- Found OpenMP_C: -openmp (found version "2.0")
-- Found OpenMP_CXX: -openmp (found version "2.0")
-- Found OpenMP: TRUE (found version "2.0")
-- Looking for CL_VERSION_3_0
-- Looking for CL_VERSION_3_0 - found
-- Found OpenCL: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/OpenCL.lib (found version "3.0")
-- OpenCL include directory: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include
-- Found Boost: C:/rtools43/x86_64-w64-mingw32.static.posix/lib/cmake/Boost-1.81.0/BoostConfig.cmake (found suitable version "1.81.0", minimum required is "1.56.0") found components: filesystem system
-- Performing Test MM_PREFETCH
-- Performing Test MM_PREFETCH - Failed
-- Performing Test MM_MALLOC
-- Performing Test MM_MALLOC - Failed
-- Looking for inet_pton
-- Looking for inet_pton - found
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/drago/AppData/Local/Temp/Rtmps5d31u/R.INSTALL15c843984516f/lightgbm/src/build
msbuild  17.8.3+195e7f5a3(.NET Framework)

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(541,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\ZERO_CHECK.vcxproj]
  Checking Build System
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(541,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\drago\ApBuilding lib_lightgbm
pData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  Building Custom Rule C:/Users/drago/AppData/Local/Temp/Rtmps5d31u/R.INSTALL15c843984516f/lightgbm/src/CMakeLists.txt
  c_api.cpp
  lightgbm_R.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(61,26): warning C4083: expected ')'; found identifier '_VCRUNTIME_DISABLED_WARNINGS' [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/c_api.cpp')

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(111,1): warning C4005: '_CRT_STRINGIZE': macro redefinition [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/c_api.cpp')
  C:\rtools43\x86_64-w64-mingw32.static.posix\include\_mingw.h(293,1):
  see previous definition of '_CRT_STRINGIZE'

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(114,1): warning C4005: '_CRT_WIDE': macro redefinition [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/c_api.cpp')
  C:\rtools43\x86_64-w64-mingw32.static.posix\include\_mingw.h(298,1):
  see previous definition of '_CRT_WIDE'

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(155,1): warning C4005: '__CRTDECL': macro redefinition [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/c_api.cpp')
  C:\rtools43\x86_64-w64-mingw32.static.posix\include\_mingw.h(405,1):
  see previous definition of '__CRTDECL'

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(345,1): warning C4005: '_CRT_DEPRECATE_TEXT': macro redefinition [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/c_api.cpp')
  C:\rtools43\x86_64-w64-mingw32.static.posix\include\_mingw.h(356,1):
  see previous definition of '_CRT_DEPRECATE_TEXT'

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(386,51): error C2065: 'uintptr_t': undeclared identifier [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/c_api.cpp')

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(386,61): error C2146: syntax error: missing ')' before identifier '_StackCookie' [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/c_api.cpp')

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(387,67): error C2065: 'uintptr_t': undeclared identifier [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/c_api.cpp')

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(387,77): error C2146: syntax error: missing ')' before identifier '_StackCookie' [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/c_api.cpp')

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(391,35): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/c_api.cpp')

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(391,18): error C2146: syntax error: missing ';' before identifier '__security_cookie' [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/c_api.cpp')

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(61,26): warning C4083: expected ')'; found identifier '_VCRUNTIME_DISABLED_WARNINGS' [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/lightgbm_R.cpp')

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(111,1): warning C4005: '_CRT_STRINGIZE': macro redefinition [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_capi_objs.vcxproj]
  (compiling source file '../src/lightgbm_R.cpp')
  C:\rtools43\x86_64-w64-mingw32.static.posix\include\_mingw.h(293,1):
  see previous definition of '_CRT_STRINGIZE'
...

C:\rtools43\x86_64-w64-mingw32.static.posix\include\float.h(270,30): error C2059: syntax error: '__declspec(nothrow)' [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_objs.vcxproj]
  (compiling source file '../src/boosting/sample_strategy.cpp')

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(386,61): error C2146: syntax error: missing ')' before identifier '_StackCookie' [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_objs.vcxproj]
  (compiling source file '../src/io/config.cpp')

C:\rtools43\x86_64-w64-mingw32.static.posix\include\stdio.h(737,3): error C2143: syntax error: missing ';' before '{' [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_objs.vcxproj]
  (compiling source file '../src/boosting/prediction_early_stop.cpp')

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\vcruntime.h(387,67): error C2065: 'uintptr_t': undeclared identifier [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_objs.vcxproj]
  (compiling source file '../src/io/config.cpp')

C:\rtools43\x86_64-w64-mingw32.static.posix\include\float.h(272,30): error C2059: syntax error: '__declspec(nothrow)' [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_objs.vcxproj]
  (compiling source file '../src/boosting/sample_strategy.cpp')

C:\rtools43\x86_64-w64-mingw32.static.posix\include\stddef.h(26,28): error C2143: syntax error: missing ';' before '__cdecl' [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_objs.vcxproj]
  (compiling source file '../src/io/bin.cpp')

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB8084: Invalid structured output from 'CL.exe': Cannot parse JsonRpc notification: ''C' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.'. [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_objs.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB8084: Invalid structured output from 'CL.exe': Unexpected header 'gth: 519'. [C:\Users\drago\AppData\Local\Temp\Rtmps5d31u\R.INSTALL15c843984516f\lightgbm\src\build\lightgbm_objs.vcxproj]

It fails if I manually set the path of opencl and boost.

Rscript build_r.R --use-gpu --opencl-library="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/OpenCL.lib" --opencl-include-dir="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include" --boost-root=C:/local/boost_1_84_0 --boost-librarydir=C:/local/boost_1_84_0/lib64-msvc-14.3 --no-build-vignettes

I trimmed the error message because it's too long.

...
C:\rtools43\x86_64-w64-mingw32.static.posix\include\malloc.h(80,10): error C1083: Cannot open include file: 'mm_malloc.h': No such file or directory [C:\Users\drago\AppData\Local\Temp\RtmpEPR342\R.INSTALL14e40d8b18d8\lightgbm\src\build\lightgbm_objs.vcxproj]
  (compiling source file '../src/treelearner/data_parallel_tree_learner.cpp')

Error in .run_shell_command(install_cmd, install_args) :
  Command failed with exit code: 1
Execution halted

Could you please check whether building gpu version on Windows using R script works?

I think folollowing the steps on https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html#id18 works.

git clone --recursive https://github.com/microsoft/LightGBM
cd LightGBM
mkdir build
cd build
cmake -A x64 -DUSE_GPU=1 -DBOOST_ROOT=C:/local/boost_1_84_0 -DBOOST_LIBRARYDIR=C:/local/boost_1_84_0/lib64-msvc-14.3 -DOpenCL_LIBRARY="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/OpenCL.lib" -DOpenCL_INCLUDE_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include" ..

But I don't know how to link this result to r package.

jameslamb commented 9 months ago

Thanks for the excellent report!

But I believe this is a duplicate of #5135.

I'm going to close this and tag you over there.

jameslamb commented 9 months ago

But I don't know how to link this result to r package.

At this time, LightGBM doesn't support compiling lib_lightgbm and then separately building an R package that uses it. You have to do the entire build in one shot.

For GPU support, that means using build_r.R as you tried.

Let's continue the rest of the conversation about that build_r.R approach on #5135 please.