From 0226069aae38168b64714622eb9aa490c58833de Mon Sep 17 00:00:00 2001 From: Corentin Kerisit Date: Mon, 24 Aug 2026 16:44:36 +0900 Subject: [PATCH] Add NCCL system-provided targets --- .github/workflows/ci.yml | 12 ++++++++++++ cuda/redist_proxy_targets.bzl | 2 ++ e2e/BUILD.bazel | 9 +++++++++ nccl/build_defs/nccl.BUILD.bazel | 18 ++++++++++++++++-- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fc8a02..f90e9f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,3 +36,15 @@ jobs: - name: Bazel analyze static cuDNN smoke (${{ matrix.cuda_version }}) working-directory: e2e run: bazel build //:cudnn_static_smoke --nobuild --platforms //:platform_linux_amd64_cuda_${{ matrix.cuda_version }} + - name: Check NCCL system dependency purity (${{ matrix.cuda_version }}) + working-directory: e2e + run: | + nccl_system_deps="$(bazel cquery 'deps(@cuda//nccl:nccl_system)' --output label --platforms //:platform_linux_amd64_cuda_${{ matrix.cuda_version }})" + if ! grep -q 'nccl_interface_library' <<< "${nccl_system_deps}"; then + echo '@cuda//nccl:nccl_system does not reach the NCCL interface library' >&2 + exit 1 + fi + if grep -q 'nccl_shared_library' <<< "${nccl_system_deps}"; then + echo '@cuda//nccl:nccl_system reaches packaged NCCL shared libraries' >&2 + exit 1 + fi diff --git a/cuda/redist_proxy_targets.bzl b/cuda/redist_proxy_targets.bzl index 8fcb2a8..1a6e197 100644 --- a/cuda/redist_proxy_targets.bzl +++ b/cuda/redist_proxy_targets.bzl @@ -108,8 +108,10 @@ REPO_PUBLIC_TARGETS = { ], "cuda_nccl": [ "nccl_shared_library", + "nccl_interface_library", "nccl_static_library", "nccl", + "nccl_system", "nccl_static", "header_list", "headers", diff --git a/e2e/BUILD.bazel b/e2e/BUILD.bazel index 6faa1b9..9b055c0 100644 --- a/e2e/BUILD.bazel +++ b/e2e/BUILD.bazel @@ -166,6 +166,15 @@ cc_binary( ], ) +cc_binary( + name = "nccl_system_smoke", + srcs = ["nccl_smoke.cc"], + deps = [ + ":smoke_test_common", + "@cuda//nccl:nccl_system", + ], +) + cc_binary( name = "nccl_static_smoke", srcs = ["nccl_smoke.cc"], diff --git a/nccl/build_defs/nccl.BUILD.bazel b/nccl/build_defs/nccl.BUILD.bazel index 66fdaf8..066f2b9 100644 --- a/nccl/build_defs/nccl.BUILD.bazel +++ b/nccl/build_defs/nccl.BUILD.bazel @@ -1,9 +1,9 @@ """BUILD definitions for nccl package""" -load("@rules_cc//cc:cc_library.bzl", "cc_library") +load("@cuda_toolkit//cuda:versions_helper.bzl", "if_version_equal_or_greater_than") load("@rules_cc//cc:cc_import.bzl", "cc_import") +load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@{cuda_redist_repo}//:version.bzl", "CUDA_VERSION") -load("@cuda_toolkit//cuda:versions_helper.bzl", "if_version_equal_or_greater_than") load("//:version.bzl", "LIB_VERSIONS") cc_import( @@ -13,6 +13,14 @@ cc_import( visibility = ["//visibility:public"], ) +cc_import( + name = "nccl_interface_library", + deps = [":headers"], + interface_library = "lib/libnccl.so", + system_provided = True, + visibility = ["//visibility:public"], +) + cc_import( name = "nccl_static_library", deps = [":headers"], @@ -29,6 +37,12 @@ cc_library( visibility = ["//visibility:public"], ) +cc_library( + name = "nccl_system", + deps = [":nccl_interface_library"], + visibility = ["//visibility:public"], +) + cc_library( name = "nccl_static", deps = [