about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix
blob: 2eb391dda46bf70da6346dc40bc79d336ab23ccf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{ lib
, backendStdenv
, fetchFromGitHub
, which
, autoAddOpenGLRunpathHook
, cuda_cccl
, cuda_cudart
, cuda_nvcc
, cudaFlags
, cudaVersion
}:
let
  # Output looks like "-gencode=arch=compute_86,code=sm_86 -gencode=arch=compute_86,code=compute_86"
  gencode = lib.concatStringsSep " " cudaFlags.gencode;
in
backendStdenv.mkDerivation (finalAttrs: {
  name = "nccl-${finalAttrs.version}-cuda-${cudaVersion}";
  version = "2.16.5-1";

  src = fetchFromGitHub {
    owner = "NVIDIA";
    repo = "nccl";
    rev = "v${finalAttrs.version}";
    hash = "sha256-JyhhYKSVIqUKIbC1rCJozPT1IrIyRLGrTjdPjJqsYaU=";
  };

  outputs = [ "out" "dev" ];

  nativeBuildInputs = [
    which
    autoAddOpenGLRunpathHook
    cuda_nvcc
  ];

  buildInputs = [
    cuda_cudart
  ]
  # NOTE: CUDA versions in Nixpkgs only use a major and minor version. When we do comparisons
  # against other version, like below, it's important that we use the same format. Otherwise,
  # we'll get incorrect results.
  # For example, lib.versionAtLeast "12.0" "12.0.0" == false.
  ++ lib.optionals (lib.versionAtLeast cudaVersion "12.0") [
    cuda_cccl
  ];

  preConfigure = ''
    patchShebangs src/collectives/device/gen_rules.sh
    makeFlagsArray+=(
      "NVCC_GENCODE=${gencode}"
    )
  '';

  makeFlags = [
    "CUDA_HOME=${cuda_nvcc}"
    "CUDA_LIB=${lib.getLib cuda_cudart}/lib"
    "CUDA_INC=${lib.getDev cuda_cudart}/include"
    "PREFIX=$(out)"
  ];

  postFixup = ''
    moveToOutput lib/libnccl_static.a $dev
  '';

  env.NIX_CFLAGS_COMPILE = toString [ "-Wno-unused-function" ];

  enableParallelBuilding = true;

  meta = with lib; {
    description = "Multi-GPU and multi-node collective communication primitives for NVIDIA GPUs";
    homepage = "https://developer.nvidia.com/nccl";
    license = licenses.bsd3;
    platforms = [ "x86_64-linux" ];
    maintainers = with maintainers; [ mdaiter orivej ];
  };
})