Skip to content

[cuda] make NCCL optional for single-GPU builds (USE_NCCL)#30

Open
Shraman123 wants to merge 1 commit into
BelixRogner:masterfrom
Shraman123:nccl-optional-single-gpu
Open

[cuda] make NCCL optional for single-GPU builds (USE_NCCL)#30
Shraman123 wants to merge 1 commit into
BelixRogner:masterfrom
Shraman123:nccl-optional-single-gpu

Conversation

@Shraman123

Copy link
Copy Markdown

Summary

USE_CUDA=ON unconditionally requires find_package(NCCL REQUIRED) and links NCCL::NCCL, even for a single GPU where no multi-GPU collective ever runs. NCCL has no official distribution for Windows, so this makes it impossible to build the CUDA backend on Windows at all - single GPU or not.

Adds a USE_NCCL option (default ON, so existing Linux/macOS builds are unaffected). When -DUSE_NCCL=OFF:

  • NCCL is no longer find_package()'d or linked.
  • nccl_gbdt.cpp / NCCLGBDT (the multi-GPU boosting path) is excluded from the build; Boosting::CreateBoosting falls back to a regular single-GPU GBDT with a warning if num_gpu > 1 is requested anyway.
  • cuda_utils.hu substitutes minimal stand-in types/functions for the handful of NCCL symbols (ncclComm_t, NCCLAllReduce, ...) that the single-GPU tree learner's shared NCCLInfo base class references even when no communicator is ever created (nccl_communicator_ stays nullptr, so these are compiled but never invoked - NCCLCHECK reports a clear fatal error in the unreachable case where one somehow is).

Test plan

  • cmake -DUSE_CUDA=ON -DUSE_NCCL=OFF -DCMAKE_CUDA_ARCHITECTURES=75 ... configures cleanly on Windows without NCCL installed
  • Full build succeeds with MSVC 2022 (Build Tools) + CUDA 12.5 (paired with the companion PR fixing unrelated MSVC/nvcc compile errors)
  • Ran real single-GPU CUDA training end-to-end on a GTX 1650 (examples/binary_classification, device_type=cuda) - logloss decreased and AUC improved over 10 iterations as expected

NCCL has no official distribution for Windows, but USE_CUDA has
unconditionally required find_package(NCCL REQUIRED) and linked
NCCL::NCCL even when only a single GPU is used and no multi-GPU
collective ever runs. That makes it impossible to build the CUDA
backend on Windows at all, single GPU or not.

Add a USE_NCCL option (default ON, matching prior behavior on
Linux/macOS). When turned OFF:
  - NCCL is no longer find_package()'d or linked.
  - nccl_gbdt.cpp/NCCLGBDT (the multi-GPU boosting path) is excluded
    from the build; Boosting::CreateBoosting falls back to a regular
    single-GPU GBDT with a warning if num_gpu > 1 is requested anyway.
  - cuda_utils.hu substitutes minimal stand-in types/functions for the
    handful of NCCL symbols (ncclComm_t, NCCLAllReduce, ...) that the
    single-GPU tree learner's shared NCCLInfo base class references
    even when no communicator is ever created (nccl_communicator_
    stays nullptr, so these are compiled but never invoked).

Verified: cmake -DUSE_CUDA=ON -DUSE_NCCL=OFF configures and builds
cleanly on Windows (MSVC + CUDA 12.5), and single-GPU CUDA training
runs end-to-end on a GTX 1650.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant