Merge pull request #276800 from SomeoneSerge/fix/cuda-no-throw

cudaPackages: eliminate exceptions

authored by Someone and committed by GitHub 86b7775f bc2c8e8e

+47 -35
+1 -1
pkgs/development/cuda-modules/cuda/overrides.nix
··· 87 cuda_nvcc = prev.cuda_nvcc.overrideAttrs ( 88 oldAttrs: { 89 90 - outputs = oldAttrs.outputs ++ [ "lib" ]; 91 92 # Patch the nvcc.profile. 93 # Syntax:
··· 87 cuda_nvcc = prev.cuda_nvcc.overrideAttrs ( 88 oldAttrs: { 89 90 + outputs = oldAttrs.outputs ++ lists.optionals (!(builtins.elem "lib" oldAttrs.outputs)) [ "lib" ]; 91 92 # Patch the nvcc.profile. 93 # Syntax:
+5 -4
pkgs/development/cuda-modules/flags.nix
··· 143 else if nixSystem == "x86_64-windows" then 144 "windows-x86_64" 145 else 146 - builtins.throw "Unsupported Nix system: ${nixSystem}"; 147 148 # Maps NVIDIA redist arch to Nix system. 149 # It is imperative that we include the boolean condition based on jetsonTargets to ensure ··· 163 else if redistArch == "windows-x86_64" then 164 "x86_64-windows" 165 else 166 - builtins.throw "Unsupported NVIDIA redist arch: ${redistArch}"; 167 168 formatCapabilities = 169 { ··· 175 176 # archNames :: List String 177 # E.g. [ "Turing" "Ampere" ] 178 archNames = lists.unique ( 179 - lists.map (cap: cudaComputeCapabilityToName.${cap} or (throw "missing cuda compute capability")) 180 - cudaCapabilities 181 ); 182 183 # realArches :: List String
··· 143 else if nixSystem == "x86_64-windows" then 144 "windows-x86_64" 145 else 146 + "unsupported"; 147 148 # Maps NVIDIA redist arch to Nix system. 149 # It is imperative that we include the boolean condition based on jetsonTargets to ensure ··· 163 else if redistArch == "windows-x86_64" then 164 "x86_64-windows" 165 else 166 + "unsupported-${redistArch}"; 167 168 formatCapabilities = 169 { ··· 175 176 # archNames :: List String 177 # E.g. [ "Turing" "Ampere" ] 178 + # 179 + # Unknown architectures are rendered as sm_XX gencode flags. 180 archNames = lists.unique ( 181 + lists.map (cap: cudaComputeCapabilityToName.${cap} or "sm_${dropDot cap}") cudaCapabilities 182 ); 183 184 # realArches :: List String
+14 -8
pkgs/development/cuda-modules/generic-builders/manifest.nix
··· 77 false 78 featureRelease; 79 # Order is important here so we use a list. 80 - additionalOutputs = builtins.filter hasOutput [ 81 "bin" 82 "lib" 83 "static" ··· 86 "sample" 87 "python" 88 ]; 89 # The out output is special -- it's the default output and we always include it. 90 - outputs = ["out"] ++ additionalOutputs; 91 in 92 outputs; 93 ··· 115 brokenConditions = {}; 116 117 src = fetchurl { 118 - url = "https://developer.download.nvidia.com/compute/${redistName}/redist/${ 119 - redistribRelease.${redistArch}.relative_path 120 - }"; 121 - inherit (redistribRelease.${redistArch}) sha256; 122 }; 123 124 postPatch = '' ··· 283 ( 284 redistArch: 285 let 286 - nixSystem = builtins.tryEval (flags.getNixSystem redistArch); 287 in 288 - if nixSystem.success then [nixSystem.value] else [] 289 ) 290 supportedRedistArchs; 291 broken = lists.any trivial.id (attrsets.attrValues finalAttrs.brokenConditions);
··· 77 false 78 featureRelease; 79 # Order is important here so we use a list. 80 + possibleOutputs = [ 81 "bin" 82 "lib" 83 "static" ··· 86 "sample" 87 "python" 88 ]; 89 + additionalOutputs = 90 + if redistArch == "unsupported" then possibleOutputs else builtins.filter hasOutput possibleOutputs; 91 # The out output is special -- it's the default output and we always include it. 92 + outputs = [ "out" ] ++ additionalOutputs; 93 in 94 outputs; 95 ··· 117 brokenConditions = {}; 118 119 src = fetchurl { 120 + url = 121 + if (builtins.hasAttr redistArch redistribRelease) then 122 + "https://developer.download.nvidia.com/compute/${redistName}/redist/${ 123 + redistribRelease.${redistArch}.relative_path 124 + }" 125 + else 126 + "cannot-construct-an-url-for-the-${redistArch}-platform"; 127 + sha256 = redistribRelease.${redistArch}.sha256 or lib.fakeHash; 128 }; 129 130 postPatch = '' ··· 289 ( 290 redistArch: 291 let 292 + nixSystem = flags.getNixSystem redistArch; 293 in 294 + lists.optionals (!(strings.hasPrefix "unsupported-" nixSystem)) [ nixSystem ] 295 ) 296 supportedRedistArchs; 297 broken = lists.any trivial.id (attrsets.attrValues finalAttrs.brokenConditions);
+15 -12
pkgs/development/cuda-modules/generic-builders/multiplex.nix
··· 59 # - Releases: ../modules/${pname}/releases/releases.nix 60 # - Package: ../modules/${pname}/releases/package.nix 61 62 # All releases across all platforms 63 # See ../modules/${pname}/releases/releases.nix 64 - allReleases = evaluatedModules.config.${pname}.releases; 65 66 # Compute versioned attribute name to be used in this package set 67 # Patch version changes should not break the build, so we only use major and minor ··· 72 # isSupported :: Package -> Bool 73 isSupported = 74 package: 75 - strings.versionAtLeast cudaVersion package.minCudaVersion 76 && strings.versionAtLeast package.maxCudaVersion cudaVersion; 77 78 # Get all of the packages for our given platform. 79 redistArch = flags.getRedistArch hostPlatform.system; 80 81 # All the supported packages we can build for our platform. 82 - # supportedPackages :: List (AttrSet Packages) 83 - supportedPackages = builtins.filter isSupported (allReleases.${redistArch} or []); 84 85 - # newestToOldestSupportedPackage :: List (AttrSet Packages) 86 - newestToOldestSupportedPackage = lists.reverseList supportedPackages; 87 - 88 - nameOfNewest = computeName (builtins.head newestToOldestSupportedPackage); 89 90 # A function which takes the `final` overlay and the `package` being built and returns 91 # a function to be consumed via `overrideAttrs`. ··· 120 attrsets.nameValuePair name fixedDrv; 121 122 # versionedDerivations :: AttrSet Derivation 123 - versionedDerivations = builtins.listToAttrs (lists.map buildPackage newestToOldestSupportedPackage); 124 125 - defaultDerivation = attrsets.optionalAttrs (versionedDerivations != {}) { 126 - ${pname} = versionedDerivations.${nameOfNewest}; 127 - }; 128 in 129 versionedDerivations // defaultDerivation; 130 in
··· 59 # - Releases: ../modules/${pname}/releases/releases.nix 60 # - Package: ../modules/${pname}/releases/package.nix 61 62 + # FIXME: do this at the module system level 63 + propagatePlatforms = lib.mapAttrs (platform: subset: map (r: r // { inherit platform; }) subset); 64 + 65 # All releases across all platforms 66 # See ../modules/${pname}/releases/releases.nix 67 + releaseSets = propagatePlatforms evaluatedModules.config.${pname}.releases; 68 69 # Compute versioned attribute name to be used in this package set 70 # Patch version changes should not break the build, so we only use major and minor ··· 75 # isSupported :: Package -> Bool 76 isSupported = 77 package: 78 + !(strings.hasPrefix "unsupported" package.platform) 79 + && strings.versionAtLeast cudaVersion package.minCudaVersion 80 && strings.versionAtLeast package.maxCudaVersion cudaVersion; 81 82 # Get all of the packages for our given platform. 83 redistArch = flags.getRedistArch hostPlatform.system; 84 85 + allReleases = builtins.concatMap (xs: xs) (builtins.attrValues releaseSets); 86 + 87 # All the supported packages we can build for our platform. 88 + # perSystemReleases :: List Package 89 + perSystemReleases = releaseSets.${redistArch} or [ ]; 90 91 + preferable = 92 + p1: p2: (isSupported p2 -> isSupported p1) && (strings.versionAtLeast p1.version p2.version); 93 + newest = builtins.head (builtins.sort preferable allReleases); 94 95 # A function which takes the `final` overlay and the `package` being built and returns 96 # a function to be consumed via `overrideAttrs`. ··· 125 attrsets.nameValuePair name fixedDrv; 126 127 # versionedDerivations :: AttrSet Derivation 128 + versionedDerivations = builtins.listToAttrs (lists.map buildPackage perSystemReleases); 129 130 + defaultDerivation = { ${pname} = (buildPackage newest).value; }; 131 in 132 versionedDerivations // defaultDerivation; 133 in
+11 -10
pkgs/development/cuda-modules/tensorrt/fixup.nix
··· 16 strings 17 versions 18 ; 19 in 20 finalAttrs: prevAttrs: { 21 # Useful for inspecting why something went wrong. ··· 58 # We need to look inside the extracted output to get the files we need. 59 sourceRoot = "TensorRT-${finalAttrs.version}"; 60 61 - buildInputs = prevAttrs.buildInputs ++ [finalAttrs.passthru.cudnn.lib]; 62 63 preInstall = 64 - let 65 - targetArch = 66 - if hostPlatform.isx86_64 then 67 - "x86_64-linux-gnu" 68 - else if hostPlatform.isAarch64 then 69 - "aarch64-linux-gnu" 70 - else 71 - throw "Unsupported architecture"; 72 - in 73 (prevAttrs.preInstall or "") 74 + '' 75 # Replace symlinks to bin and lib with the actual directories from targets. ··· 107 }; 108 109 meta = prevAttrs.meta // { 110 homepage = "https://developer.nvidia.com/tensorrt"; 111 maintainers = prevAttrs.meta.maintainers ++ [maintainers.aidalgol]; 112 };
··· 16 strings 17 versions 18 ; 19 + targetArch = 20 + if hostPlatform.isx86_64 then 21 + "x86_64-linux-gnu" 22 + else if hostPlatform.isAarch64 then 23 + "aarch64-linux-gnu" 24 + else 25 + "unsupported"; 26 in 27 finalAttrs: prevAttrs: { 28 # Useful for inspecting why something went wrong. ··· 65 # We need to look inside the extracted output to get the files we need. 66 sourceRoot = "TensorRT-${finalAttrs.version}"; 67 68 + buildInputs = prevAttrs.buildInputs ++ [ finalAttrs.passthru.cudnn.lib ]; 69 70 preInstall = 71 (prevAttrs.preInstall or "") 72 + '' 73 # Replace symlinks to bin and lib with the actual directories from targets. ··· 105 }; 106 107 meta = prevAttrs.meta // { 108 + badPlatforms = 109 + prevAttrs.meta.badPlatforms or [ ] 110 + ++ lib.optionals (targetArch == "unsupported") [ hostPlatform.system ]; 111 homepage = "https://developer.nvidia.com/tensorrt"; 112 maintainers = prevAttrs.meta.maintainers ++ [maintainers.aidalgol]; 113 };
+1
pkgs/development/python-modules/tensorflow/default.nix
··· 480 }; 481 482 meta = with lib; { 483 changelog = "https://github.com/tensorflow/tensorflow/releases/tag/v${version}"; 484 description = "Computation using data flow graphs for scalable machine learning"; 485 homepage = "http://tensorflow.org";
··· 480 }; 481 482 meta = with lib; { 483 + badPlatforms = lib.optionals cudaSupport lib.platforms.darwin; 484 changelog = "https://github.com/tensorflow/tensorflow/releases/tag/v${version}"; 485 description = "Computation using data flow graphs for scalable machine learning"; 486 homepage = "http://tensorflow.org";