about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorConnor Baker <connor.baker@tweag.io>2023-12-04 14:53:44 -0500
committerGitHub <noreply@github.com>2023-12-04 14:53:44 -0500
commit35f91964c9909c29b8ff38464b6463564fc0eaa7 (patch)
tree3681bca2137da0269eacc9529d437272f3c7cfdd /pkgs
parent32f61c9c322305005c4aa1761c851e5aaa30e893 (diff)
parentebef0c31074009f49a7d2e900deff099137ed0fd (diff)
Merge pull request #272093 from ConnorBaker/fix/nccl-tests-support-cuda-prev-11_4
cudaPackages.nccl-tests: support building with CUDA < 11.4 with cudatoolkit
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/libraries/science/math/nccl/tests.nix131
1 files changed, 73 insertions, 58 deletions
diff --git a/pkgs/development/libraries/science/math/nccl/tests.nix b/pkgs/development/libraries/science/math/nccl/tests.nix
index 9d826b92f164a..5c2f29b7ed564 100644
--- a/pkgs/development/libraries/science/math/nccl/tests.nix
+++ b/pkgs/development/libraries/science/math/nccl/tests.nix
@@ -1,69 +1,84 @@
-{ backendStdenv
-, config
-, cuda_cccl
-, cuda_cudart
-, cuda_nvcc
-, cudaVersion
-, fetchFromGitHub
-, gitUpdater
-, lib
-, mpi
-, mpiSupport ? false
-, nccl
-, which
+# NOTE: Though NCCL tests is called within the cudaPackages package set, we avoid passing in
+# the names of dependencies from that package set directly to avoid evaluation errors
+# in the case redistributable packages are not available.
+{
+  config,
+  cudaPackages,
+  fetchFromGitHub,
+  gitUpdater,
+  lib,
+  mpi,
+  mpiSupport ? false,
+  which,
 }:
+let
+  inherit (cudaPackages)
+    backendStdenv
+    cuda_cccl
+    cuda_cudart
+    cuda_nvcc
+    cudatoolkit
+    cudaVersion
+    nccl
+    ;
+in
+backendStdenv.mkDerivation (
+  finalAttrs: {
 
-backendStdenv.mkDerivation (finalAttrs: {
+    pname = "nccl-tests";
+    version = "2.13.8";
 
-  pname = "nccl-tests";
-  version = "2.13.8";
+    src = fetchFromGitHub {
+      owner = "NVIDIA";
+      repo = finalAttrs.pname;
+      rev = "v${finalAttrs.version}";
+      hash = "sha256-dxLoflsTHDBnZRTzoXdm30OyKpLlRa73b784YWALBHg=";
+    };
 
-  src = fetchFromGitHub {
-    owner = "NVIDIA";
-    repo = finalAttrs.pname;
-    rev = "v${finalAttrs.version}";
-    hash = "sha256-dxLoflsTHDBnZRTzoXdm30OyKpLlRa73b784YWALBHg=";
-  };
+    strictDeps = true;
 
-  strictDeps = true;
+    nativeBuildInputs =
+      [which]
+      ++ lib.optionals (lib.versionOlder cudaVersion "11.4") [cudatoolkit]
+      ++ lib.optionals (lib.versionAtLeast cudaVersion "11.4") [cuda_nvcc];
 
-  nativeBuildInputs = [
-    cuda_nvcc
-    which
-  ];
-
-  buildInputs = [
-    cuda_cudart
-    nccl
-  ] ++ lib.optionals (lib.versionAtLeast cudaVersion "12.0") [
-    cuda_cccl.dev # <nv/target>
-  ] ++ lib.optional mpiSupport mpi;
+    buildInputs =
+      [nccl]
+      ++ lib.optionals (lib.versionOlder cudaVersion "11.4") [cudatoolkit]
+      ++ lib.optionals (lib.versionAtLeast cudaVersion "11.4") [
+        cuda_nvcc.dev # crt/host_config.h
+        cuda_cudart
+      ]
+      ++ lib.optionals (lib.versionAtLeast cudaVersion "12.0") [
+        cuda_cccl.dev # <nv/target>
+      ]
+      ++ lib.optionals mpiSupport [mpi];
 
-  makeFlags = [
-    "CUDA_HOME=${cuda_nvcc}"
-    "NCCL_HOME=${nccl}"
-  ] ++ lib.optionals mpiSupport [
-    "MPI=1"
-  ];
+    makeFlags =
+      ["NCCL_HOME=${nccl}"]
+      ++ lib.optionals (lib.versionOlder cudaVersion "11.4") ["CUDA_HOME=${cudatoolkit}"]
+      ++ lib.optionals (lib.versionAtLeast cudaVersion "11.4") ["CUDA_HOME=${cuda_nvcc}"]
+      ++ lib.optionals mpiSupport ["MPI=1"];
 
-  enableParallelBuilding = true;
+    enableParallelBuilding = true;
 
-  installPhase = ''
-    mkdir -p $out/bin
-    cp -r build/* $out/bin/
-  '';
+    installPhase = ''
+      mkdir -p $out/bin
+      cp -r build/* $out/bin/
+    '';
 
-  passthru.updateScript = gitUpdater {
-    inherit (finalAttrs) pname version;
-    rev-prefix = "v";
-  };
+    passthru.updateScript = gitUpdater {
+      inherit (finalAttrs) pname version;
+      rev-prefix = "v";
+    };
 
-  meta = with lib; {
-    description = "Tests to check both the performance and the correctness of NVIDIA NCCL operations";
-    homepage = "https://github.com/NVIDIA/nccl-tests";
-    platforms = platforms.linux;
-    license = licenses.bsd3;
-    broken = !config.cudaSupport || (mpiSupport && mpi == null);
-    maintainers = with maintainers; [ jmillerpdt ] ++ teams.cuda.members;
-  };
-})
+    meta = with lib; {
+      description = "Tests to check both the performance and the correctness of NVIDIA NCCL operations";
+      homepage = "https://github.com/NVIDIA/nccl-tests";
+      platforms = platforms.linux;
+      license = licenses.bsd3;
+      broken = !config.cudaSupport || (mpiSupport && mpi == null);
+      maintainers = with maintainers; [jmillerpdt] ++ teams.cuda.members;
+    };
+  }
+)