_cuda: introduce to organize CUDA package set backbone

Signed-off-by: Connor Baker <ConnorBaker01@gmail.com>
(cherry picked from commit 688e14d21a)
This commit is contained in:
Connor Baker 2025-05-20 09:32:03 -07:00 committed by github-actions[bot]
parent 420ef69fa8
commit c3fdb7a77c
45 changed files with 186 additions and 156 deletions

View file

@ -115,8 +115,8 @@ All new projects should use the CUDA redistributables available in [`cudaPackage
### Updating supported compilers and GPUs {#updating-supported-compilers-and-gpus} ### Updating supported compilers and GPUs {#updating-supported-compilers-and-gpus}
1. Update `nvccCompatibilities` in `pkgs/development/cuda-modules/lib/data/nvcc.nix` to include the newest release of NVCC, as well as any newly supported host compilers. 1. Update `nvccCompatibilities` in `pkgs/development/cuda-modules/_cuda/data/nvcc.nix` to include the newest release of NVCC, as well as any newly supported host compilers.
2. Update `cudaCapabilityToInfo` in `pkgs/development/cuda-modules/lib/data/cuda.nix` to include any new GPUs supported by the new release of CUDA. 2. Update `cudaCapabilityToInfo` in `pkgs/development/cuda-modules/_cuda/data/cuda.nix` to include any new GPUs supported by the new release of CUDA.
### Updating the CUDA Toolkit runfile installer {#updating-the-cuda-toolkit} ### Updating the CUDA Toolkit runfile installer {#updating-the-cuda-toolkit}

View file

@ -1,63 +1,5 @@
{ cudaLib, lib }: { lib }:
{ {
/**
All CUDA capabilities, sorted by version.
NOTE: Since the capabilities are sorted by version and architecture/family-specific features are
appended to the minor version component, the sorted list groups capabilities by baseline feature
set.
# Type
```
allSortedCudaCapabilities :: [CudaCapability]
```
# Example
```
allSortedCudaCapabilities = [
"5.0"
"5.2"
"6.0"
"6.1"
"7.0"
"7.2"
"7.5"
"8.0"
"8.6"
"8.7"
"8.9"
"9.0"
"9.0a"
"10.0"
"10.0a"
"10.0f"
"10.1"
"10.1a"
"10.1f"
"10.3"
"10.3a"
"10.3f"
];
```
*/
allSortedCudaCapabilities = lib.sort lib.versionOlder (
lib.attrNames cudaLib.data.cudaCapabilityToInfo
);
/**
Mapping of CUDA micro-architecture name to capabilities belonging to that micro-architecture.
# Type
```
cudaArchNameToCapabilities :: AttrSet NonEmptyStr (NonEmptyListOf CudaCapability)
```
*/
cudaArchNameToCapabilities = lib.groupBy (
cudaCapability: cudaLib.data.cudaCapabilityToInfo.${cudaCapability}.archName
) cudaLib.data.allSortedCudaCapabilities;
/** /**
Attribute set of supported CUDA capability mapped to information about that capability. Attribute set of supported CUDA capability mapped to information about that capability.

View file

@ -1,9 +1,7 @@
{ cudaLib, lib }: { lib }:
{ {
# See ./cuda.nix for documentation. # See ./cuda.nix for documentation.
inherit (import ./cuda.nix { inherit cudaLib lib; }) inherit (import ./cuda.nix { inherit lib; })
allSortedCudaCapabilities
cudaArchNameToCapabilities
cudaCapabilityToInfo cudaCapabilityToInfo
; ;
@ -28,5 +26,5 @@
cudaPackagesPath :: Path cudaPackagesPath :: Path
``` ```
*/ */
cudaPackagesPath = ./..; cudaPackagesPath = ./../../..;
} }

View file

@ -0,0 +1,65 @@
{
lib,
bootstrapData,
db,
}:
bootstrapData
// {
/**
All CUDA capabilities, sorted by version.
NOTE: Since the capabilities are sorted by version and architecture/family-specific features are
appended to the minor version component, the sorted list groups capabilities by baseline feature
set.
# Type
```
allSortedCudaCapabilities :: [CudaCapability]
```
# Example
```
allSortedCudaCapabilities = [
"5.0"
"5.2"
"6.0"
"6.1"
"7.0"
"7.2"
"7.5"
"8.0"
"8.6"
"8.7"
"8.9"
"9.0"
"9.0a"
"10.0"
"10.0a"
"10.0f"
"10.1"
"10.1a"
"10.1f"
"10.3"
"10.3a"
"10.3f"
];
```
*/
allSortedCudaCapabilities = lib.sort lib.versionOlder (lib.attrNames db.cudaCapabilityToInfo);
/**
Mapping of CUDA micro-architecture name to capabilities belonging to that micro-architecture.
# Type
```
cudaArchNameToCapabilities :: AttrSet NonEmptyStr (NonEmptyListOf CudaCapability)
```
*/
cudaArchNameToCapabilities = lib.groupBy (
cudaCapability: db.cudaCapabilityToInfo.${cudaCapability}.archName
) db.allSortedCudaCapabilities;
}

View file

@ -0,0 +1,30 @@
# The _cuda attribute set is a fixed-point which contains the static functionality required to construct CUDA package
# sets. For example, `_cuda.cudaData` includes information about NVIDIA's redistributables (such as the names NVIDIA
# uses for different systems), `_cuda.cudaLib` contains utility functions like `formatCapabilities` (which generate
# common arguments passed to NVCC and `cmakeFlags`), and `_cuda.cudaFixups` contains `callPackage`-able functions
# which are provided to the corresponding package's `overrideAttrs` attribute to provide package-specific fixups
# out of scope of the generic redistributable builder.
#
# Since this attribute set is used to construct the CUDA package sets, it must exist outside the fixed point of the
# package sets. Make these attributes available directly in the package set construction could cause confusion if
# users override the attribute set with the expection that changes will be reflected in the enclosing CUDA package
# set. To avoid this, we declare `_cuda` and inherit its members here, at top-level. (This also allows us to benefit
# from import caching, as it should be evaluated once per system, rather than per-system and CUDA package set.)
let
lib = import ../../../../lib;
in
lib.fixedPoints.makeExtensible (final: {
bootstrapData = import ./db/bootstrap {
inherit lib;
};
db = import ./db {
inherit (final) bootstrapData db;
inherit lib;
};
fixups = import ./fixups { inherit lib; };
lib = import ./lib {
_cuda = final;
inherit lib;
};
})

View file

@ -1,6 +1,4 @@
let { lib }:
lib = import ../../../../lib;
in
lib.concatMapAttrs ( lib.concatMapAttrs (
fileName: _type: fileName: _type:
let let

View file

@ -1,5 +1,5 @@
{ {
cudaLib, _cuda,
cudaOlder, cudaOlder,
cudaPackages, cudaPackages,
cudaMajorMinorVersion, cudaMajorMinorVersion,
@ -103,7 +103,7 @@ finalAttrs: prevAttrs: {
# unless it is not available, in which case the default cudnn derivation will be used. # unless it is not available, in which case the default cudnn derivation will be used.
cudnn = cudnn =
let let
desiredName = cudaLib.utils.mkVersionedName "cudnn" ( desiredName = _cuda.lib.mkVersionedName "cudnn" (
lib.versions.majorMinor finalAttrs.passthru.featureRelease.cudnnVersion lib.versions.majorMinor finalAttrs.passthru.featureRelease.cudnnVersion
); );
in in

View file

@ -1,4 +1,4 @@
{ cudaLib, lib }: { _cuda, lib }:
{ {
/** /**
Evaluate assertions and add error context to return value. Evaluate assertions and add error context to return value.
@ -16,7 +16,7 @@
_evaluateAssertions = _evaluateAssertions =
assertions: assertions:
let let
failedAssertionsString = cudaLib.utils._mkFailedAssertionsString assertions; failedAssertionsString = _cuda.lib._mkFailedAssertionsString assertions;
in in
if failedAssertionsString == "" then if failedAssertionsString == "" then
true true
@ -45,7 +45,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils._mkFailedAssertionsString` usage examples ## `_cuda.lib._mkFailedAssertionsString` usage examples
```nix ```nix
_mkFailedAssertionsString [ _mkFailedAssertionsString [
@ -103,7 +103,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils._mkMissingPackagesAssertions` usage examples ## `_cuda.lib._mkMissingPackagesAssertions` usage examples
```nix ```nix
{ {
@ -114,7 +114,7 @@
}: }:
let let
inherit (lib.attrsets) recursiveUpdate; inherit (lib.attrsets) recursiveUpdate;
inherit (cudaLib.utils) _mkMissingPackagesAssertions; inherit (_cuda.lib) _mkMissingPackagesAssertions;
in in
prevAttrs: { prevAttrs: {
passthru = prevAttrs.passthru or { } // { passthru = prevAttrs.passthru or { } // {

View file

@ -92,7 +92,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils._mkCudaVariant` usage examples ## `_cuda.lib._mkCudaVariant` usage examples
```nix ```nix
_mkCudaVariant "11.0" _mkCudaVariant "11.0"

View file

@ -1,7 +1,10 @@
{ cudaLib, lib }: {
_cuda,
lib,
}:
{ {
# See ./assertions.nix for documentation. # See ./assertions.nix for documentation.
inherit (import ./assertions.nix { inherit cudaLib lib; }) inherit (import ./assertions.nix { inherit _cuda lib; })
_evaluateAssertions _evaluateAssertions
_mkFailedAssertionsString _mkFailedAssertionsString
_mkMissingPackagesAssertions _mkMissingPackagesAssertions
@ -16,13 +19,13 @@
; ;
# See ./meta.nix for documentation. # See ./meta.nix for documentation.
inherit (import ./meta.nix { inherit cudaLib lib; }) inherit (import ./meta.nix { inherit _cuda lib; })
_mkMetaBadPlatforms _mkMetaBadPlatforms
_mkMetaBroken _mkMetaBroken
; ;
# See ./redist.nix for documentation. # See ./redist.nix for documentation.
inherit (import ./redist.nix { inherit cudaLib lib; }) inherit (import ./redist.nix { inherit _cuda lib; })
_redistSystemIsSupported _redistSystemIsSupported
getNixSystems getNixSystems
getRedistSystem getRedistSystem
@ -30,7 +33,7 @@
; ;
# See ./strings.nix for documentation. # See ./strings.nix for documentation.
inherit (import ./strings.nix { inherit cudaLib lib; }) inherit (import ./strings.nix { inherit _cuda lib; })
dotsToUnderscores dotsToUnderscores
dropDots dropDots
formatCapabilities formatCapabilities
@ -42,7 +45,7 @@
; ;
# See ./versions.nix for documentation. # See ./versions.nix for documentation.
inherit (import ./versions.nix { inherit cudaLib lib; }) inherit (import ./versions.nix { inherit _cuda lib; })
majorMinorPatch majorMinorPatch
trimComponents trimComponents
; ;

View file

@ -1,4 +1,4 @@
{ cudaLib, lib }: { _cuda, lib }:
{ {
/** /**
Returns a list of bad platforms for a given package if assertsions in `finalAttrs.passthru.platformAssertions` Returns a list of bad platforms for a given package if assertsions in `finalAttrs.passthru.platformAssertions`
@ -18,7 +18,7 @@
_mkMetaBadPlatforms = _mkMetaBadPlatforms =
warn: finalAttrs: warn: finalAttrs:
let let
failedAssertionsString = cudaLib.utils._mkFailedAssertionsString finalAttrs.passthru.platformAssertions; failedAssertionsString = _cuda.lib._mkFailedAssertionsString finalAttrs.passthru.platformAssertions;
hasFailedAssertions = failedAssertionsString != ""; hasFailedAssertions = failedAssertionsString != "";
finalStdenv = finalAttrs.finalPackage.stdenv; finalStdenv = finalAttrs.finalPackage.stdenv;
in in
@ -62,7 +62,7 @@
_mkMetaBroken = _mkMetaBroken =
warn: finalAttrs: warn: finalAttrs:
let let
failedAssertionsString = cudaLib.utils._mkFailedAssertionsString finalAttrs.passthru.brokenAssertions; failedAssertionsString = _cuda.lib._mkFailedAssertionsString finalAttrs.passthru.brokenAssertions;
hasFailedAssertions = failedAssertionsString != ""; hasFailedAssertions = failedAssertionsString != "";
in in
lib.warnIf (warn && hasFailedAssertions) lib.warnIf (warn && hasFailedAssertions)

View file

@ -1,4 +1,4 @@
{ cudaLib, lib }: { _cuda, lib }:
{ {
/** /**
Returns a boolean indicating whether the provided redist system is supported by any of the provided redist systems. Returns a boolean indicating whether the provided redist system is supported by any of the provided redist systems.
@ -27,7 +27,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils._redistSystemIsSupported` usage examples ## `cudaLib._redistSystemIsSupported` usage examples
```nix ```nix
_redistSystemIsSupported "linux-x86_64" [ "linux-x86_64" ] _redistSystemIsSupported "linux-x86_64" [ "linux-x86_64" ]
@ -81,7 +81,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils.getNixSystems` usage examples ## `cudaLib.getNixSystems` usage examples
```nix ```nix
getNixSystems "linux-sbsa" getNixSystems "linux-sbsa"
@ -137,7 +137,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils.getRedistSystem` usage examples ## `cudaLib.getRedistSystem` usage examples
```nix ```nix
getRedistSystem true "aarch64-linux" getRedistSystem true "aarch64-linux"
@ -181,7 +181,7 @@
mkRedistUrl = mkRedistUrl =
redistName: relativePath: redistName: relativePath:
lib.concatStringsSep "/" ( lib.concatStringsSep "/" (
[ cudaLib.data.redistUrlPrefix ] [ _cuda.db.redistUrlPrefix ]
++ ( ++ (
if redistName != "tensorrt" then if redistName != "tensorrt" then
[ [

View file

@ -1,4 +1,7 @@
{ cudaLib, lib }: { _cuda, lib }:
let
cudaLib = _cuda.lib;
in
{ {
/** /**
Replaces dots in a string with underscores. Replaces dots in a string with underscores.
@ -18,7 +21,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils.dotsToUnderscores` usage examples ## `cudaLib.dotsToUnderscores` usage examples
```nix ```nix
dotsToUnderscores "1.2.3" dotsToUnderscores "1.2.3"
@ -46,7 +49,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils.dropDots` usage examples ## `cudaLib.dropDots` usage examples
```nix ```nix
dropDots "1.2.3" dropDots "1.2.3"
@ -110,7 +113,7 @@
realArches :: List String realArches :: List String
``` ```
*/ */
realArches = lib.map cudaLib.utils.mkRealArchitecture cudaCapabilities; realArches = lib.map cudaLib.mkRealArchitecture cudaCapabilities;
/** /**
The virtual architectures for the given CUDA capabilities. The virtual architectures for the given CUDA capabilities.
@ -124,7 +127,7 @@
virtualArches :: List String virtualArches :: List String
``` ```
*/ */
virtualArches = lib.map cudaLib.utils.mkVirtualArchitecture cudaCapabilities; virtualArches = lib.map cudaLib.mkVirtualArchitecture cudaCapabilities;
/** /**
The gencode flags for the given CUDA capabilities. The gencode flags for the given CUDA capabilities.
@ -137,8 +140,8 @@
*/ */
gencode = gencode =
let let
base = lib.map (cudaLib.utils.mkGencodeFlag "sm") cudaCapabilities; base = lib.map (cudaLib.mkGencodeFlag "sm") cudaCapabilities;
forward = cudaLib.utils.mkGencodeFlag "compute" (lib.last cudaCapabilities); forward = cudaLib.mkGencodeFlag "compute" (lib.last cudaCapabilities);
in in
base ++ lib.optionals cudaForwardCompat [ forward ]; base ++ lib.optionals cudaForwardCompat [ forward ];
in in
@ -190,7 +193,7 @@
cmakeCudaArchitecturesString :: String cmakeCudaArchitecturesString :: String
``` ```
*/ */
cmakeCudaArchitecturesString = cudaLib.utils.mkCmakeCudaArchitecturesString cudaCapabilities; cmakeCudaArchitecturesString = cudaLib.mkCmakeCudaArchitecturesString cudaCapabilities;
/** /**
The gencode string for the given CUDA capabilities. The gencode string for the given CUDA capabilities.
@ -222,7 +225,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils.mkCmakeCudaArchitecturesString` usage examples ## `cudaLib.mkCmakeCudaArchitecturesString` usage examples
```nix ```nix
mkCmakeCudaArchitecturesString [ "8.9" "10.0a" ] mkCmakeCudaArchitecturesString [ "8.9" "10.0a" ]
@ -230,7 +233,7 @@
``` ```
::: :::
*/ */
mkCmakeCudaArchitecturesString = lib.concatMapStringsSep ";" cudaLib.utils.dropDots; mkCmakeCudaArchitecturesString = lib.concatMapStringsSep ";" cudaLib.dropDots;
/** /**
Produces a gencode flag from a CUDA capability. Produces a gencode flag from a CUDA capability.
@ -254,7 +257,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils.mkGencodeFlag` usage examples ## `cudaLib.mkGencodeFlag` usage examples
```nix ```nix
mkGencodeFlag "sm" "8.9" mkGencodeFlag "sm" "8.9"
@ -270,7 +273,7 @@
mkGencodeFlag = mkGencodeFlag =
archPrefix: cudaCapability: archPrefix: cudaCapability:
let let
cap = cudaLib.utils.dropDots cudaCapability; cap = cudaLib.dropDots cudaCapability;
in in
"-gencode=arch=compute_${cap},code=${archPrefix}_${cap}"; "-gencode=arch=compute_${cap},code=${archPrefix}_${cap}";
@ -292,7 +295,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils.mkRealArchitecture` usage examples ## `cudaLib.mkRealArchitecture` usage examples
```nix ```nix
mkRealArchitecture "8.9" mkRealArchitecture "8.9"
@ -305,7 +308,7 @@
``` ```
::: :::
*/ */
mkRealArchitecture = cudaCapability: "sm_" + cudaLib.utils.dropDots cudaCapability; mkRealArchitecture = cudaCapability: "sm_" + cudaLib.dropDots cudaCapability;
/** /**
Create a versioned attribute name from a version by replacing dots with underscores. Create a versioned attribute name from a version by replacing dots with underscores.
@ -329,7 +332,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils.mkVersionedName` usage examples ## `cudaLib.mkVersionedName` usage examples
```nix ```nix
mkVersionedName "hello" "1.2.3" mkVersionedName "hello" "1.2.3"
@ -342,7 +345,7 @@
``` ```
::: :::
*/ */
mkVersionedName = name: version: "${name}_${cudaLib.utils.dotsToUnderscores version}"; mkVersionedName = name: version: "${name}_${cudaLib.dotsToUnderscores version}";
/** /**
Produces a virtual architecture string from a CUDA capability. Produces a virtual architecture string from a CUDA capability.
@ -362,7 +365,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils.mkVirtualArchitecture` usage examples ## `cudaLib.mkVirtualArchitecture` usage examples
```nix ```nix
mkVirtualArchitecture "8.9" mkVirtualArchitecture "8.9"
@ -375,5 +378,5 @@
``` ```
::: :::
*/ */
mkVirtualArchitecture = cudaCapability: "compute_" + cudaLib.utils.dropDots cudaCapability; mkVirtualArchitecture = cudaCapability: "compute_" + cudaLib.dropDots cudaCapability;
} }

View file

@ -1,4 +1,7 @@
{ cudaLib, lib }: { _cuda, lib }:
let
cudaLib = _cuda.lib;
in
{ {
/** /**
Extracts the major, minor, and patch version from a string. Extracts the major, minor, and patch version from a string.
@ -18,7 +21,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils.majorMinorPatch` usage examples ## `_cuda.lib.majorMinorPatch` usage examples
```nix ```nix
majorMinorPatch "11.0.3.4" majorMinorPatch "11.0.3.4"
@ -26,7 +29,7 @@
``` ```
::: :::
*/ */
majorMinorPatch = cudaLib.utils.trimComponents 3; majorMinorPatch = cudaLib.trimComponents 3;
/** /**
Get a version string with no more than than the specified number of components. Get a version string with no more than than the specified number of components.
@ -48,7 +51,7 @@
# Examples # Examples
:::{.example} :::{.example}
## `cudaLib.utils.trimComponents` usage examples ## `_cuda.lib.trimComponents` usage examples
```nix ```nix
trimComponents 1 "1.2.3.4" trimComponents 1 "1.2.3.4"

View file

@ -69,7 +69,7 @@ let
# Patch version changes should not break the build, so we only use major and minor # Patch version changes should not break the build, so we only use major and minor
# computeName :: RedistribRelease -> String # computeName :: RedistribRelease -> String
computeName = computeName =
{ version, ... }: cudaLib.utils.mkVersionedName redistName (lib.versions.majorMinor version); { version, ... }: cudaLib.mkVersionedName redistName (lib.versions.majorMinor version);
in in
final: _: final: _:
let let

View file

@ -108,7 +108,7 @@ let
# Patch version changes should not break the build, so we only use major and minor # Patch version changes should not break the build, so we only use major and minor
# computeName :: RedistribRelease -> String # computeName :: RedistribRelease -> String
computeName = computeName =
{ version, ... }: cudaLib.utils.mkVersionedName redistName (lib.versions.majorMinor version); { version, ... }: cudaLib.mkVersionedName redistName (lib.versions.majorMinor version);
in in
final: _: final: _:
let let

View file

@ -5,8 +5,7 @@
autoPatchelfHook, autoPatchelfHook,
backendStdenv, backendStdenv,
callPackage, callPackage,
cudaFixups, _cuda,
cudaLib,
fetchurl, fetchurl,
lib, lib,
markForCudatoolkitRootHook, markForCudatoolkitRootHook,
@ -45,7 +44,7 @@ let
# Last step before returning control to `callPackage` (adds the `.override` method) # Last step before returning control to `callPackage` (adds the `.override` method)
# we'll apply (`overrideAttrs`) necessary package-specific "fixup" functions. # we'll apply (`overrideAttrs`) necessary package-specific "fixup" functions.
# Order is significant. # Order is significant.
maybeFixup = cudaFixups.${pname} or null; maybeFixup = _cuda.fixups.${pname} or null;
fixup = if maybeFixup != null then callPackage maybeFixup { } else { }; fixup = if maybeFixup != null then callPackage maybeFixup { } else { };
# Get the redist systems for which package provides distributables. # Get the redist systems for which package provides distributables.
@ -54,9 +53,9 @@ let
# redistSystem :: String # redistSystem :: String
# The redistSystem is the name of the system for which the redistributable is built. # The redistSystem is the name of the system for which the redistributable is built.
# It is `"unsupported"` if the redistributable is not supported on the target system. # It is `"unsupported"` if the redistributable is not supported on the target system.
redistSystem = cudaLib.utils.getRedistSystem backendStdenv.hasJetsonCudaCapability hostPlatform.system; redistSystem = _cuda.lib.getRedistSystem backendStdenv.hasJetsonCudaCapability hostPlatform.system;
sourceMatchesHost = lib.elem hostPlatform.system (cudaLib.utils.getNixSystems redistSystem); sourceMatchesHost = lib.elem hostPlatform.system (_cuda.lib.getNixSystems redistSystem);
in in
(backendStdenv.mkDerivation (finalAttrs: { (backendStdenv.mkDerivation (finalAttrs: {
# NOTE: Even though there's no actual buildPhase going on here, the derivations of the # NOTE: Even though there's no actual buildPhase going on here, the derivations of the
@ -327,7 +326,7 @@ in
broken = lists.any trivial.id (attrsets.attrValues finalAttrs.brokenConditions); broken = lists.any trivial.id (attrsets.attrValues finalAttrs.brokenConditions);
platforms = trivial.pipe supportedRedistSystems [ platforms = trivial.pipe supportedRedistSystems [
# Map each redist system to the equivalent nix systems. # Map each redist system to the equivalent nix systems.
(lib.concatMap cudaLib.utils.getNixSystems) (lib.concatMap _cuda.lib.getNixSystems)
# Take all the unique values. # Take all the unique values.
lib.unique lib.unique
# Sort the list. # Sort the list.

View file

@ -64,8 +64,7 @@ let
# Compute versioned attribute name to be used in this package set # 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 # Patch version changes should not break the build, so we only use major and minor
# computeName :: Package -> String # computeName :: Package -> String
computeName = computeName = { version, ... }: cudaLib.mkVersionedName pname (lib.versions.majorMinor version);
{ version, ... }: cudaLib.utils.mkVersionedName pname (lib.versions.majorMinor version);
# The newest package for each major-minor version, with newest first. # The newest package for each major-minor version, with newest first.
# newestPackages :: List Package # newestPackages :: List Package

View file

@ -1,13 +0,0 @@
let
lib = import ../../../../lib;
in
lib.fixedPoints.makeExtensible (final: {
data = import ./data {
inherit lib;
cudaLib = final;
};
utils = import ./utils {
inherit lib;
cudaLib = final;
};
})

View file

@ -7,7 +7,7 @@
# Cf. https://github.com/NixOS/nixpkgs/pull/218265 for context # Cf. https://github.com/NixOS/nixpkgs/pull/218265 for context
{ {
config, config,
cudaLib, _cuda,
cudaMajorMinorVersion, cudaMajorMinorVersion,
lib, lib,
pkgs, pkgs,
@ -16,8 +16,8 @@
}: }:
let let
inherit (builtins) toJSON; inherit (builtins) toJSON;
inherit (cudaLib.data) allSortedCudaCapabilities cudaCapabilityToInfo nvccCompatibilities; inherit (_cuda.db) allSortedCudaCapabilities cudaCapabilityToInfo nvccCompatibilities;
inherit (cudaLib.utils) inherit (_cuda.lib)
_cudaCapabilityIsDefault _cudaCapabilityIsDefault
_cudaCapabilityIsSupported _cudaCapabilityIsSupported
_evaluateAssertions _evaluateAssertions

View file

@ -1,4 +1,5 @@
{ {
cudaData,
cudaLib, cudaLib,
cudaNamePrefix, cudaNamePrefix,
lib, lib,
@ -6,8 +7,8 @@
}: }:
let let
inherit (builtins) deepSeq toJSON tryEval; inherit (builtins) deepSeq toJSON tryEval;
inherit (cudaLib.data) cudaCapabilityToInfo; inherit (cudaData) cudaCapabilityToInfo;
inherit (cudaLib.utils) formatCapabilities; inherit (cudaLib) formatCapabilities;
inherit (lib.asserts) assertMsg; inherit (lib.asserts) assertMsg;
in in
# When changing names or formats: pause, validate, and update the assert # When changing names or formats: pause, validate, and update the assert

View file

@ -2723,9 +2723,8 @@ with pkgs;
cron = isc-cron; cron = isc-cron;
cudaLib = import ../development/cuda-modules/lib; # Top-level fix-point used in `cudaPackages`' internals
_cuda = import ../development/cuda-modules/_cuda;
cudaFixups = import ../development/cuda-modules/fixups;
cudaPackages_11_0 = callPackage ./cuda-packages.nix { cudaMajorMinorVersion = "11.0"; }; cudaPackages_11_0 = callPackage ./cuda-packages.nix { cudaMajorMinorVersion = "11.0"; };
cudaPackages_11_1 = callPackage ./cuda-packages.nix { cudaMajorMinorVersion = "11.1"; }; cudaPackages_11_1 = callPackage ./cuda-packages.nix { cudaMajorMinorVersion = "11.1"; };

View file

@ -22,7 +22,7 @@
# I've (@connorbaker) attempted to do that, though I'm unsure of how this will interact with overrides. # I've (@connorbaker) attempted to do that, though I'm unsure of how this will interact with overrides.
{ {
config, config,
cudaLib, _cuda,
cudaMajorMinorVersion, cudaMajorMinorVersion,
lib, lib,
newScope, newScope,
@ -38,25 +38,28 @@ let
versions versions
; ;
cudaLib = _cuda.lib;
# Since Jetson capabilities are never built by default, we can check if any of them were requested # Since Jetson capabilities are never built by default, we can check if any of them were requested
# through final.config.cudaCapabilities and use that to determine if we should change some manifest versions. # through final.config.cudaCapabilities and use that to determine if we should change some manifest versions.
# Copied from backendStdenv. # Copied from backendStdenv.
jetsonCudaCapabilities = lib.filter ( jetsonCudaCapabilities = lib.filter (
cudaCapability: cudaLib.data.cudaCapabilityToInfo.${cudaCapability}.isJetson cudaCapability: _cuda.db.cudaCapabilityToInfo.${cudaCapability}.isJetson
) cudaLib.data.allSortedCudaCapabilities; ) _cuda.db.allSortedCudaCapabilities;
hasJetsonCudaCapability = hasJetsonCudaCapability =
lib.intersectLists jetsonCudaCapabilities (config.cudaCapabilities or [ ]) != [ ]; lib.intersectLists jetsonCudaCapabilities (config.cudaCapabilities or [ ]) != [ ];
redistSystem = cudaLib.utils.getRedistSystem hasJetsonCudaCapability stdenv.hostPlatform.system; redistSystem = _cuda.lib.getRedistSystem hasJetsonCudaCapability stdenv.hostPlatform.system;
passthruFunction = final: { passthruFunction = final: {
# NOTE: # NOTE:
# It is important that cudaLib and cudaFixups are not part of the package set fixed-point. As described by # It is important that _cuda is not part of the package set fixed-point. As described by
# @SomeoneSerge: # @SomeoneSerge:
# > The layering should be: configuration -> (identifies/is part of) cudaPackages -> (is built using) cudaLib. # > The layering should be: configuration -> (identifies/is part of) cudaPackages -> (is built using) cudaLib.
# > No arrows should point in the reverse directions. # > No arrows should point in the reverse directions.
# That is to say that cudaLib should only know about package sets and configurations, because it implements # That is to say that cudaLib should only know about package sets and configurations, because it implements
# functionality for interpreting configurations, resolving them against data, and constructing package sets. # functionality for interpreting configurations, resolving them against data, and constructing package sets.
# This decision is driven both by a separation of concerns and by "NAMESET STRICTNESS" (see above). # This decision is driven both by a separation of concerns and by "NAMESET STRICTNESS" (see above).
# Also see the comment in `pkgs/top-level/all-packages.nix` about the `_cuda` attribute.
inherit cudaMajorMinorVersion; inherit cudaMajorMinorVersion;
@ -77,17 +80,17 @@ let
}; };
flags = flags =
cudaLib.utils.formatCapabilities { cudaLib.formatCapabilities {
inherit (final.backendStdenv) cudaCapabilities cudaForwardCompat; inherit (final.backendStdenv) cudaCapabilities cudaForwardCompat;
inherit (cudaLib.data) cudaCapabilityToInfo; inherit (_cuda.db) cudaCapabilityToInfo;
} }
# TODO(@connorbaker): Enable the corresponding warnings in `../development/cuda-modules/aliases.nix` after some # TODO(@connorbaker): Enable the corresponding warnings in `../development/cuda-modules/aliases.nix` after some
# time to allow users to migrate to cudaLib and backendStdenv. # time to allow users to migrate to cudaLib and backendStdenv.
// { // {
inherit (cudaLib.utils) dropDots; inherit (cudaLib) dropDots;
cudaComputeCapabilityToName = cudaComputeCapabilityToName =
cudaCapability: cudaLib.data.cudaCapabilityToInfo.${cudaCapability}.archName; cudaCapability: _cuda.db.cudaCapabilityToInfo.${cudaCapability}.archName;
dropDot = cudaLib.utils.dropDots; dropDot = cudaLib.dropDots;
isJetsonBuild = final.backendStdenv.hasJetsonCudaCapability; isJetsonBuild = final.backendStdenv.hasJetsonCudaCapability;
}; };

View file

@ -14,7 +14,7 @@
let let
lib = import ../../lib; lib = import ../../lib;
cudaLib = import ../development/cuda-modules/lib; inherit (import ../development/cuda-modules/_cuda) cudaLib;
in in
{ {
@ -27,7 +27,7 @@ in
# Attributes passed to nixpkgs. # Attributes passed to nixpkgs.
nixpkgsArgs ? { nixpkgsArgs ? {
config = { config = {
allowUnfreePredicate = cudaLib.utils.allowUnfreeCudaPredicate; allowUnfreePredicate = cudaLib.allowUnfreeCudaPredicate;
"${variant}Support" = true; "${variant}Support" = true;
inHydra = true; inHydra = true;