diff --git a/pkgs/development/cuda-modules/cusparselt/extension.nix b/pkgs/development/cuda-modules/cusparselt/extension.nix new file mode 100644 index 000000000000..f7ecfb0f12b6 --- /dev/null +++ b/pkgs/development/cuda-modules/cusparselt/extension.nix @@ -0,0 +1,144 @@ +# Support matrix can be found at +# https://docs.nvidia.com/deeplearning/cudnn/archives/cudnn-880/support-matrix/index.html +{ + lib, + stdenv, + cudaVersion, + flags, + mkVersionedPackageName, +}: +let + inherit (lib) + attrsets + lists + modules + versions + strings + trivial + ; + + inherit (stdenv) hostPlatform; + + redistName = "cusparselt"; + pname = "libcusparse_lt"; + + cusparseltVersions = [ + "0.7.1" + ]; + + # Manifests :: { redistrib, feature } + + # Each release of cusparselt gets mapped to an evaluated module for that release. + # From there, we can get the min/max CUDA versions supported by that release. + # listOfManifests :: List Manifests + listOfManifests = + let + configEvaluator = + fullCusparseltVersion: + modules.evalModules { + modules = [ + ../modules + # We need to nest the manifests in a config.cusparselt.manifests attribute so the + # module system can evaluate them. + { + cusparselt.manifests = { + redistrib = trivial.importJSON (./manifests + "/redistrib_${fullCusparseltVersion}.json"); + feature = trivial.importJSON (./manifests + "/feature_${fullCusparseltVersion}.json"); + }; + } + ]; + }; + # Un-nest the manifests attribute set. + releaseGrabber = evaluatedModules: evaluatedModules.config.cusparselt.manifests; + in + lists.map (trivial.flip trivial.pipe [ + configEvaluator + releaseGrabber + ]) cusparseltVersions; + + # Our cudaVersion tells us which version of CUDA we're building against. + # The subdirectories in lib/ tell us which versions of CUDA are supported. + # Typically the names will look like this: + # + # - 10.2 + # - 11 + # - 11.0 + # - 12 + + # libPath :: String + libPath = + let + cudaMajorMinor = versions.majorMinor cudaVersion; + cudaMajor = versions.major cudaVersion; + in + if cudaMajorMinor == "10.2" then cudaMajorMinor else cudaMajor; + + # A release is supported if it has a libPath that matches our CUDA version for our platform. + # LibPath are not constant across the same release -- one platform may support fewer + # CUDA versions than another. + # redistArch :: String + redistArch = flags.getRedistArch hostPlatform.system; + # platformIsSupported :: Manifests -> Boolean + platformIsSupported = + { feature, redistrib, ... }: + (attrsets.attrByPath [ + pname + redistArch + ] null feature) != null; + + # TODO(@connorbaker): With an auxiliary file keeping track of the CUDA versions each release supports, + # we could filter out releases that don't support our CUDA version. + # However, we don't have that currently, so we make a best-effort to try to build TensorRT with whatever + # libPath corresponds to our CUDA version. + # supportedManifests :: List Manifests + supportedManifests = builtins.filter platformIsSupported listOfManifests; + + # Compute versioned attribute name to be used in this package set + # Patch version changes should not break the build, so we only use major and minor + # computeName :: RedistribRelease -> String + computeName = { version, ... }: mkVersionedPackageName redistName version; +in +final: _: +let + # buildCusparseltPackage :: Manifests -> AttrSet Derivation + buildCusparseltPackage = + { redistrib, feature }: + let + drv = final.callPackage ../generic-builders/manifest.nix { + inherit pname redistName; + redistribRelease = redistrib.${pname}; + featureRelease = feature.${pname}; + }; + fixedDrv = drv.overrideAttrs (prevAttrs: { + buildInputs = + prevAttrs.buildInputs + ++ lists.optionals (strings.versionOlder cudaVersion "11.4") [ final.cudatoolkit ] + ++ lists.optionals (strings.versionAtLeast cudaVersion "11.4") ( + [ final.libcublas.lib ] + # For some reason, the 1.4.x release of cusparselt requires the cudart library. + ++ lists.optionals (strings.hasPrefix "1.4" redistrib.${pname}.version) [ final.cuda_cudart.lib ] + ); + meta = prevAttrs.meta // { + description = "cuSPARSELt: A High-Performance CUDA Library for Sparse Matrix-Matrix Multiplication"; + homepage = "https://developer.nvidia.com/cusparselt-downloads"; + + maintainers = prevAttrs.meta.maintainers ++ [ lib.maintainers.sepiabrown ]; + license = lib.licenses.unfreeRedistributable // { + shortName = "cuSPARSELt EULA"; + fullName = "cuSPARSELt SUPPLEMENT TO SOFTWARE LICENSE AGREEMENT FOR NVIDIA SOFTWARE DEVELOPMENT KITS"; + url = "https://docs.nvidia.com/cuda/cusparselt/license.html"; + }; + }; + }); + in + attrsets.nameValuePair (computeName redistrib.${pname}) fixedDrv; + + extension = + let + nameOfNewest = computeName (lists.last supportedManifests).redistrib.${pname}; + drvs = builtins.listToAttrs (lists.map buildCusparseltPackage supportedManifests); + containsDefault = attrsets.optionalAttrs (drvs != { }) { cusparselt = drvs.${nameOfNewest}; }; + in + drvs // containsDefault; +in +extension diff --git a/pkgs/development/cuda-modules/cusparselt/manifests/feature_0.7.1.json b/pkgs/development/cuda-modules/cusparselt/manifests/feature_0.7.1.json new file mode 100644 index 000000000000..0b368e22bb24 --- /dev/null +++ b/pkgs/development/cuda-modules/cusparselt/manifests/feature_0.7.1.json @@ -0,0 +1,44 @@ +{ + "libcusparse_lt": { + "linux-aarch64": { + "outputs": { + "bin": false, + "dev": true, + "doc": false, + "lib": true, + "sample": false, + "static": true + } + }, + "linux-sbsa": { + "outputs": { + "bin": false, + "dev": true, + "doc": false, + "lib": true, + "sample": false, + "static": true + } + }, + "linux-x86_64": { + "outputs": { + "bin": false, + "dev": true, + "doc": false, + "lib": true, + "sample": false, + "static": true + } + }, + "windows-x86_64": { + "outputs": { + "bin": false, + "dev": true, + "doc": false, + "lib": false, + "sample": false, + "static": false + } + } + } +} diff --git a/pkgs/development/cuda-modules/cusparselt/manifests/redistrib_0.7.1.json b/pkgs/development/cuda-modules/cusparselt/manifests/redistrib_0.7.1.json new file mode 100644 index 000000000000..b9609bd4532a --- /dev/null +++ b/pkgs/development/cuda-modules/cusparselt/manifests/redistrib_0.7.1.json @@ -0,0 +1,35 @@ +{ + "release_date": "2025-02-25", + "release_label": "0.7.1", + "release_product": "cusparselt", + "libcusparse_lt": { + "name": "NVIDIA cuSPARSELt", + "license": "cuSPARSELt", + "license_path": "libcusparse_lt/LICENSE.txt", + "version": "0.7.1.0", + "linux-x86_64": { + "relative_path": "libcusparse_lt/linux-x86_64/libcusparse_lt-linux-x86_64-0.7.1.0-archive.tar.xz", + "sha256": "a0d885837887c73e466a31b4e86aaae2b7d0cc9c5de0d40921dbe2a15dbd6a88", + "md5": "b2e5f3c9b9d69e1e0b55b16de33fdc6e", + "size": "353151840" + }, + "linux-sbsa": { + "relative_path": "libcusparse_lt/linux-sbsa/libcusparse_lt-linux-sbsa-0.7.1.0-archive.tar.xz", + "sha256": "4a131d0a54728e53ba536b50bb65380603456f1656e7df8ee52e285618a0b57c", + "md5": "612a712c7da6e801ee773687e99af87e", + "size": "352406784" + }, + "windows-x86_64": { + "relative_path": "libcusparse_lt/windows-x86_64/libcusparse_lt-windows-x86_64-0.7.1.0-archive.zip", + "sha256": "004bcb1b700c24ca8d60a8ddd2124640f61138a6c29914d2afaa0bfa0d0e3cf2", + "md5": "a1d8df8dc8ff4b3bd0e859f992f8f392", + "size": "268594665" + }, + "linux-aarch64": { + "relative_path": "libcusparse_lt/linux-aarch64/libcusparse_lt-linux-aarch64-0.7.1.0-archive.tar.xz", + "sha256": "d3b0a660fd552e0bd9a4491b15299d968674833483d5f164cfea35e70646136c", + "md5": "54e3f3b28c94118991ce54ec38f531fb", + "size": "5494380" + } + } +} diff --git a/pkgs/development/cuda-modules/modules/cusparselt/default.nix b/pkgs/development/cuda-modules/modules/cusparselt/default.nix new file mode 100644 index 000000000000..745bad811c05 --- /dev/null +++ b/pkgs/development/cuda-modules/modules/cusparselt/default.nix @@ -0,0 +1,4 @@ +{ options, ... }: +{ + options.cusparselt.manifests = options.generic.manifests; +} diff --git a/pkgs/development/cuda-modules/modules/default.nix b/pkgs/development/cuda-modules/modules/default.nix index ccccd871479e..a173d1cae360 100644 --- a/pkgs/development/cuda-modules/modules/default.nix +++ b/pkgs/development/cuda-modules/modules/default.nix @@ -4,6 +4,7 @@ # Always after generic ./cuda ./cudnn + ./cusparselt ./cutensor ./tensorrt ]; diff --git a/pkgs/top-level/cuda-packages.nix b/pkgs/top-level/cuda-packages.nix index 4da43f0bd117..3770aee3bae7 100644 --- a/pkgs/top-level/cuda-packages.nix +++ b/pkgs/top-level/cuda-packages.nix @@ -148,6 +148,9 @@ let (callPackage ../development/cuda-modules/cutensor/extension.nix { inherit cudaVersion flags mkVersionedPackageName; }) + (callPackage ../development/cuda-modules/cusparselt/extension.nix { + inherit cudaVersion flags mkVersionedPackageName; + }) (callPackage ../development/cuda-modules/generic-builders/multiplex.nix { inherit cudaVersion flags mkVersionedPackageName; pname = "tensorrt"; diff --git a/pkgs/top-level/release-cuda.nix b/pkgs/top-level/release-cuda.nix index 55796a21291d..4ebabe05e1f3 100644 --- a/pkgs/top-level/release-cuda.nix +++ b/pkgs/top-level/release-cuda.nix @@ -23,6 +23,7 @@ let || builtins.elem license.shortName [ "CUDA EULA" "cuDNN EULA" + "cuSPARSELt EULA" "cuTENSOR EULA" "NVidia OptiX EULA" ]