summaryrefslogtreecommitdiffstats
path: root/pkgs/development/cuda-modules
diff options
context:
space:
mode:
authorSomeone Serge <sergei.kozlukov@aalto.fi>2023-12-25 22:46:52 +0000
committerSomeone Serge <sergei.kozlukov@aalto.fi>2023-12-26 03:33:17 +0000
commit576c4f4af5094340f6bbd1a74a54a5e28b6e916d (patch)
tree42760a51afeea8108937f38f2845d032d6442f2d /pkgs/development/cuda-modules
parent5391c840e705b65b5ad8c18d6956466477a554fc (diff)
cudaPackages: eliminate exceptions
as they break common nixpkgs tools like lib.meta, cf. https://github.com/NixOS/nixpkgs/issues/276795
Diffstat (limited to 'pkgs/development/cuda-modules')
-rw-r--r--pkgs/development/cuda-modules/cuda/overrides.nix2
-rw-r--r--pkgs/development/cuda-modules/flags.nix9
-rw-r--r--pkgs/development/cuda-modules/generic-builders/manifest.nix10
-rw-r--r--pkgs/development/cuda-modules/generic-builders/multiplex.nix27
-rw-r--r--pkgs/development/cuda-modules/tensorrt/fixup.nix21
5 files changed, 38 insertions, 31 deletions
diff --git a/pkgs/development/cuda-modules/cuda/overrides.nix b/pkgs/development/cuda-modules/cuda/overrides.nix
index 225dada7c16b..db11cd937792 100644
--- a/pkgs/development/cuda-modules/cuda/overrides.nix
+++ b/pkgs/development/cuda-modules/cuda/overrides.nix
@@ -77,7 +77,7 @@ attrsets.filterAttrs (attr: _: (builtins.hasAttr attr prev)) {
cuda_nvcc = prev.cuda_nvcc.overrideAttrs (
oldAttrs: {
- outputs = oldAttrs.outputs ++ [ "lib" ];
+ outputs = oldAttrs.outputs ++ lists.optionals (!(builtins.elem "lib" oldAttrs.outputs)) [ "lib" ];
# Patch the nvcc.profile.
# Syntax:
diff --git a/pkgs/development/cuda-modules/flags.nix b/pkgs/development/cuda-modules/flags.nix
index ab44ced45232..a123c7bce5a1 100644
--- a/pkgs/development/cuda-modules/flags.nix
+++ b/pkgs/development/cuda-modules/flags.nix
@@ -143,7 +143,7 @@ let
else if nixSystem == "x86_64-windows" then
"windows-x86_64"
else
- builtins.throw "Unsupported Nix system: ${nixSystem}";
+ "unsupported";
# Maps NVIDIA redist arch to Nix system.
# It is imperative that we include the boolean condition based on jetsonTargets to ensure
@@ -163,7 +163,7 @@ let
else if redistArch == "windows-x86_64" then
"x86_64-windows"
else
- builtins.throw "Unsupported NVIDIA redist arch: ${redistArch}";
+ "unsupported-${redistArch}";
formatCapabilities =
{
@@ -175,9 +175,10 @@ let
# archNames :: List String
# E.g. [ "Turing" "Ampere" ]
+ #
+ # Unknown architectures are rendered as sm_XX gencode flags.
archNames = lists.unique (
- lists.map (cap: cudaComputeCapabilityToName.${cap} or (throw "missing cuda compute capability"))
- cudaCapabilities
+ lists.map (cap: cudaComputeCapabilityToName.${cap} or "sm_${dropDot cap}") cudaCapabilities
);
# realArches :: List String
diff --git a/pkgs/development/cuda-modules/generic-builders/manifest.nix b/pkgs/development/cuda-modules/generic-builders/manifest.nix
index 67f6e93559c4..5f86c0874688 100644
--- a/pkgs/development/cuda-modules/generic-builders/manifest.nix
+++ b/pkgs/development/cuda-modules/generic-builders/manifest.nix
@@ -77,7 +77,7 @@ backendStdenv.mkDerivation (
false
featureRelease;
# Order is important here so we use a list.
- additionalOutputs = builtins.filter hasOutput [
+ possibleOutputs = [
"bin"
"lib"
"static"
@@ -86,8 +86,10 @@ backendStdenv.mkDerivation (
"sample"
"python"
];
+ additionalOutputs =
+ if redistArch == "unsupported" then possibleOutputs else builtins.filter hasOutput possibleOutputs;
# The out output is special -- it's the default output and we always include it.
- outputs = ["out"] ++ additionalOutputs;
+ outputs = [ "out" ] ++ additionalOutputs;
in
outputs;
@@ -283,9 +285,9 @@ backendStdenv.mkDerivation (
(
redistArch:
let
- nixSystem = builtins.tryEval (flags.getNixSystem redistArch);
+ nixSystem = flags.getNixSystem redistArch;
in
- if nixSystem.success then [nixSystem.value] else []
+ lists.optionals (!(strings.hasPrefix "unsupported-" nixSystem)) [ nixSystem ]
)
supportedRedistArchs;
broken = lists.any trivial.id (attrsets.attrValues finalAttrs.brokenConditions);
diff --git a/pkgs/development/cuda-modules/generic-builders/multiplex.nix b/pkgs/development/cuda-modules/generic-builders/multiplex.nix
index b8053094bcc8..5480da730726 100644
--- a/pkgs/development/cuda-modules/generic-builders/multiplex.nix
+++ b/pkgs/development/cuda-modules/generic-builders/multiplex.nix
@@ -59,9 +59,12 @@ let
# - Releases: ../modules/${pname}/releases/releases.nix
# - Package: ../modules/${pname}/releases/package.nix
+ # FIXME: do this at the module system level
+ propagatePlatforms = lib.mapAttrs (platform: subset: map (r: r // { inherit platform; }) subset);
+
# All releases across all platforms
# See ../modules/${pname}/releases/releases.nix
- allReleases = evaluatedModules.config.${pname}.releases;
+ releaseSets = propagatePlatforms evaluatedModules.config.${pname}.releases;
# 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
@@ -72,20 +75,22 @@ let
# isSupported :: Package -> Bool
isSupported =
package:
- strings.versionAtLeast cudaVersion package.minCudaVersion
+ !(strings.hasPrefix "unsupported" package.platform)
+ && strings.versionAtLeast cudaVersion package.minCudaVersion
&& strings.versionAtLeast package.maxCudaVersion cudaVersion;
# Get all of the packages for our given platform.
redistArch = flags.getRedistArch hostPlatform.system;
- # All the supported packages we can build for our platform.
- # supportedPackages :: List (AttrSet Packages)
- supportedPackages = builtins.filter isSupported (allReleases.${redistArch} or []);
+ allReleases = builtins.concatMap (xs: xs) (builtins.attrValues releaseSets);
- # newestToOldestSupportedPackage :: List (AttrSet Packages)
- newestToOldestSupportedPackage = lists.reverseList supportedPackages;
+ # All the supported packages we can build for our platform.
+ # perSystemReleases :: List Package
+ perSystemReleases = releaseSets.${redistArch} or [ ];
- nameOfNewest = computeName (builtins.head newestToOldestSupportedPackage);
+ preferable =
+ p1: p2: (isSupported p2 -> isSupported p1) && (strings.versionAtLeast p1.version p2.version);
+ newest = builtins.head (builtins.sort preferable allReleases);
# A function which takes the `final` overlay and the `package` being built and returns
# a function to be consumed via `overrideAttrs`.
@@ -120,11 +125,9 @@ let
attrsets.nameValuePair name fixedDrv;
# versionedDerivations :: AttrSet Derivation
- versionedDerivations = builtins.listToAttrs (lists.map buildPackage newestToOldestSupportedPackage);
+ versionedDerivations = builtins.listToAttrs (lists.map buildPackage perSystemReleases);
- defaultDerivation = attrsets.optionalAttrs (versionedDerivations != {}) {
- ${pname} = versionedDerivations.${nameOfNewest};
- };
+ defaultDerivation = { ${pname} = (buildPackage newest).value; };
in
versionedDerivations // defaultDerivation;
in
diff --git a/pkgs/development/cuda-modules/tensorrt/fixup.nix b/pkgs/development/cuda-modules/tensorrt/fixup.nix
index d713189328ed..43a7dfb81784 100644
--- a/pkgs/development/cuda-modules/tensorrt/fixup.nix
+++ b/pkgs/development/cuda-modules/tensorrt/fixup.nix
@@ -16,6 +16,13 @@ let
strings
versions
;
+ targetArch =
+ if hostPlatform.isx86_64 then
+ "x86_64-linux-gnu"
+ else if hostPlatform.isAarch64 then
+ "aarch64-linux-gnu"
+ else
+ "unsupported";
in
finalAttrs: prevAttrs: {
# Useful for inspecting why something went wrong.
@@ -58,18 +65,9 @@ finalAttrs: prevAttrs: {
# We need to look inside the extracted output to get the files we need.
sourceRoot = "TensorRT-${finalAttrs.version}";
- buildInputs = prevAttrs.buildInputs ++ [finalAttrs.passthru.cudnn.lib];
+ buildInputs = prevAttrs.buildInputs ++ [ finalAttrs.passthru.cudnn.lib ];
preInstall =
- let
- targetArch =
- if hostPlatform.isx86_64 then
- "x86_64-linux-gnu"
- else if hostPlatform.isAarch64 then
- "aarch64-linux-gnu"
- else
- throw "Unsupported architecture";
- in
(prevAttrs.preInstall or "")
+ ''
# Replace symlinks to bin and lib with the actual directories from targets.
@@ -107,6 +105,9 @@ finalAttrs: prevAttrs: {
};
meta = prevAttrs.meta // {
+ badPlatforms =
+ prevAttrs.meta.badPlatforms or [ ]
+ ++ lib.optionals (targetArch == "unsupported") [ hostPlatform.system ];
homepage = "https://developer.nvidia.com/tensorrt";
maintainers = prevAttrs.meta.maintainers ++ [maintainers.aidalgol];
};