nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 124 lines 5.0 kB view raw
1{ 2 _cuda, 3 backendStdenv, 4 buildRedist, 5 lib, 6 libcublas, 7 cuda_nvrtc, 8 patchelf, 9 zlib, 10}: 11buildRedist ( 12 finalAttrs: 13 let 14 inherit (backendStdenv) cudaCapabilities; 15 cudnnAtLeast = lib.versionAtLeast finalAttrs.version; 16 cudnnOlder = lib.versionOlder finalAttrs.version; 17 in 18 { 19 redistName = "cudnn"; 20 pname = "cudnn"; 21 22 outputs = [ 23 "out" 24 "dev" 25 "include" 26 "lib" 27 "static" 28 ]; 29 30 buildInputs = [ 31 # NOTE: Verions of CUDNN after 9.0 no longer depend on libcublas: 32 # https://docs.nvidia.com/deeplearning/cudnn/latest/release-notes.html?highlight=cublas#cudnn-9-0-0 33 # However, NVIDIA only provides libcublasLT via the libcublas package. 34 (lib.getLib libcublas) 35 zlib 36 ]; 37 38 # Tell autoPatchelf about runtime dependencies. *_infer* libraries only 39 # exist in CuDNN 8. 40 # NOTE: Versions from CUDNN releases have four components. 41 postFixup = lib.optionalString (cudnnAtLeast "8" && cudnnOlder "9") '' 42 ${lib.getExe patchelf} ''${!outputLib:?}/lib/libcudnn.so --add-needed libcudnn_cnn_infer.so 43 ${lib.getExe patchelf} ''${!outputLib:?}/lib/libcudnn_ops_infer.so --add-needed libcublas.so --add-needed libcublasLt.so 44 ''; 45 46 # CuDNN depends on libnvrtc.so at runtime, as mentioned here in one small error description 47 # https://docs.nvidia.com/deeplearning/cudnn/backend/latest/api/cudnn-graph-library.html 48 appendRunpaths = [ 49 "${lib.getLib cuda_nvrtc}/lib" 50 ]; 51 52 # NOTE: 53 # With cuDNN forward compatiblity, all non-natively supported compute capabilities JIT compile PTX kernels. 54 # 55 # While this is sub-optimal and we should warn the user and encourage them to use a newer version of cuDNN, we 56 # have no clean mechanism by which we can warn the user, or allow silencing such a warning if the use of an 57 # older cuDNN is intentional. 58 # 59 # As such, we only warn about capabilities which are no longer supported by cuDNN. 60 # 61 # NOTE: 62 # 63 # NVIDIA promises forward compatibility of cuDNN for major versions of CUDA. As an example, the cuDNN build for 64 # CUDA 12 is compatible with all, and will remain compatible with, all CUDA 12 releases. However, this does not 65 # extend to static linking with CUDA 11! 66 # 67 # We don't need to check the CUDA version to see if it falls within some supported range -- if a user decides 68 # to do static linking against some odd combination of CUDA 11 and cuDNN, that's on them. 69 # 70 platformAssertions = 71 let 72 # Create variables and use logical OR to allow short-circuiting. 73 74 cudnnAtLeast912 = cudnnAtLeast "9.12"; 75 cudnnAtLeast88 = cudnnAtLeast912 || cudnnAtLeast "8.8"; 76 cudnnAtLeast85 = cudnnAtLeast88 || cudnnAtLeast "8.5"; 77 78 allCCNewerThan75 = lib.all (lib.flip lib.versionAtLeast "7.5") cudaCapabilities; 79 allCCNewerThan50 = allCCNewerThan75 || lib.all (lib.flip lib.versionAtLeast "5.0") cudaCapabilities; 80 allCCNewerThan35 = allCCNewerThan50 || lib.all (lib.flip lib.versionAtLeast "3.5") cudaCapabilities; 81 in 82 [ 83 # https://docs.nvidia.com/deeplearning/cudnn/archives/cudnn-850/support-matrix/index.html#cudnn-cuda-hardware-versions 84 { 85 message = 86 "cuDNN releases since 8.5 (found ${finalAttrs.version})" 87 + " support CUDA compute capabilities 3.5 and newer (found ${builtins.toJSON cudaCapabilities})"; 88 assertion = cudnnAtLeast85 -> allCCNewerThan35; 89 } 90 # https://docs.nvidia.com/deeplearning/cudnn/archives/cudnn-880/support-matrix/index.html#cudnn-cuda-hardware-versions 91 { 92 message = 93 "cuDNN releases since 8.8 (found ${finalAttrs.version})" 94 + " support CUDA compute capabilities 5.0 and newer (found ${builtins.toJSON cudaCapabilities})"; 95 assertion = cudnnAtLeast88 -> allCCNewerThan50; 96 } 97 # https://docs.nvidia.com/deeplearning/cudnn/backend/v9.12.0/reference/support-matrix.html#gpu-cuda-toolkit-and-cuda-driver-requirements 98 { 99 message = 100 "cuDNN releases since 9.12 (found ${finalAttrs.version})" 101 + " support CUDA compute capabilities 7.5 and newer (found ${builtins.toJSON cudaCapabilities})"; 102 assertion = cudnnAtLeast912 -> allCCNewerThan75; 103 } 104 ]; 105 106 meta = { 107 description = "GPU-accelerated library of primitives for deep neural networks"; 108 longDescription = '' 109 The NVIDIA CUDA Deep Neural Network library (cuDNN) is a GPU-accelerated library of primitives for deep neural 110 networks. 111 ''; 112 homepage = "https://developer.nvidia.com/cudnn"; 113 changelog = "https://docs.nvidia.com/deeplearning/cudnn/backend/latest/release-notes.html"; 114 115 license = _cuda.lib.licenses.cudnn; 116 117 maintainers = with lib.maintainers; [ 118 mdaiter 119 samuela 120 connorbaker 121 ]; 122 }; 123 } 124)