-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cudaPackages: point nvcc at a compatible -ccbin #218265
Changes from all commits
94bbbb0
cf7fb1d
7939795
e305011
d378cc6
5f4bdbe
1724812
2b69d61
c376c54
8bf5f5a
dd2b276
0c25f5a
ac64f07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ config | ||
, lib | ||
, cudatoolkit | ||
, cudaVersion | ||
}: | ||
|
||
# Type aliases | ||
|
@@ -13,14 +13,21 @@ | |
|
||
let | ||
inherit (lib) attrsets lists strings trivial versions; | ||
cudaVersion = cudatoolkit.version; | ||
|
||
# Flags are determined based on your CUDA toolkit by default. You may benefit | ||
# from improved performance, reduced file size, or greater hardware suppport by | ||
# passing a configuration based on your specific GPU environment. | ||
# | ||
# config.cudaCapabilities: list of hardware generations to support (e.g., "8.0") | ||
# config.cudaForwardCompat: bool for compatibility with future GPU generations | ||
# config.cudaCapabilities :: List Capability | ||
# List of hardware generations to build. | ||
# E.g. [ "8.0" ] | ||
# Currently, the last item is considered the optional forward-compatibility arch, | ||
# but this may change in the future. | ||
# | ||
# config.cudaForwardCompat :: Bool | ||
# Whether to include the forward compatibility gencode (+PTX) | ||
# to support future GPU generations. | ||
# E.g. true | ||
# | ||
# Please see the accompanying documentation or https://github.com/NixOS/nixpkgs/pull/205351 | ||
|
||
|
@@ -40,6 +47,9 @@ let | |
# GPUs which are supported by the provided CUDA version. | ||
supportedGpus = builtins.filter isSupported gpus; | ||
|
||
# supportedCapabilities :: List Capability | ||
supportedCapabilities = lists.map (gpu: gpu.computeCapability) supportedGpus; | ||
|
||
# cudaArchNameToVersions :: AttrSet String (List String) | ||
# Maps the name of a GPU architecture to different versions of that architecture. | ||
# For example, "Ampere" maps to [ "8.0" "8.6" "8.7" ]. | ||
|
@@ -50,12 +60,6 @@ let | |
(gpu: gpu.archName) | ||
supportedGpus; | ||
|
||
# cudaArchNames :: List String | ||
# NOTE: It's important that we don't rely on builtins.attrNames cudaArchNameToVersions here; | ||
# otherwise, we'll get the names sorted in alphabetical order. The JSON array we read them | ||
# from is already sorted, so we'll preserve that order here. | ||
cudaArchNames = lists.unique (lists.map (gpu: gpu.archName) supportedGpus); | ||
SomeoneSerge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# cudaComputeCapabilityToName :: AttrSet String String | ||
# Maps the version of a GPU architecture to the name of that architecture. | ||
# For example, "8.0" maps to "Ampere". | ||
|
@@ -68,23 +72,6 @@ let | |
supportedGpus | ||
); | ||
|
||
# cudaComputeCapabilities :: List String | ||
# NOTE: It's important that we don't rely on builtins.attrNames cudaComputeCapabilityToName here; | ||
# otherwise, we'll get the versions sorted in alphabetical order. The JSON array we read them | ||
# from is already sorted, so we'll preserve that order here. | ||
# Use the user-provided list of CUDA capabilities if it's provided. | ||
cudaComputeCapabilities = config.cudaCapabilities | ||
or (lists.map (gpu: gpu.computeCapability) supportedGpus); | ||
|
||
# cudaForwardComputeCapability :: String | ||
cudaForwardComputeCapability = (lists.last cudaComputeCapabilities) + "+PTX"; | ||
|
||
# cudaComputeCapabilitiesAndForward :: List String | ||
# The list of supported CUDA architectures, including the forward compatibility architecture. | ||
# If forward compatibility is disabled, this will be the same as cudaComputeCapabilities. | ||
cudaComputeCapabilitiesAndForward = cudaComputeCapabilities | ||
++ lists.optional (config.cudaForwardCompat or true) cudaForwardComputeCapability; | ||
|
||
# dropDot :: String -> String | ||
dropDot = ver: builtins.replaceStrings [ "." ] [ "" ] ver; | ||
|
||
|
@@ -102,38 +89,68 @@ let | |
"-gencode=arch=compute_${dropDot computeCapability},code=${feat}_${dropDot computeCapability}" | ||
); | ||
|
||
# cudaRealArches :: List String | ||
# The real architectures are physical architectures supported by the CUDA version. | ||
# For example, "sm_80". | ||
cudaRealArches = archMapper "sm" cudaComputeCapabilities; | ||
|
||
# cudaVirtualArches :: List String | ||
# The virtual architectures are typically used for forward compatibility, when trying to support | ||
# an architecture newer than the CUDA version allows. | ||
# For example, "compute_80". | ||
cudaVirtualArches = archMapper "compute" cudaComputeCapabilities; | ||
|
||
# cudaArches :: List String | ||
# By default, build for all supported architectures and forward compatibility via a virtual | ||
# architecture for the newest supported architecture. | ||
cudaArches = cudaRealArches ++ | ||
lists.optional (config.cudaForwardCompat or true) (lists.last cudaVirtualArches); | ||
|
||
# cudaGencode :: List String | ||
# A list of CUDA gencode arguments to pass to NVCC. | ||
cudaGencode = | ||
let | ||
base = gencodeMapper "sm" cudaComputeCapabilities; | ||
forwardCompat = gencodeMapper "compute" [ (lists.last cudaComputeCapabilities) ]; | ||
in | ||
base ++ lists.optionals (config.cudaForwardCompat or true) forwardCompat; | ||
formatCapabilities = { cudaCapabilities, enableForwardCompat ? true }: rec { | ||
SomeoneSerge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
inherit cudaCapabilities enableForwardCompat; | ||
|
||
# archNames :: List String | ||
# E.g. [ "Turing" "Ampere" ] | ||
archNames = lists.unique (builtins.map (cap: cudaComputeCapabilityToName.${cap}) cudaCapabilities); | ||
|
||
# realArches :: List String | ||
# The real architectures are physical architectures supported by the CUDA version. | ||
# E.g. [ "sm_75" "sm_86" ] | ||
realArches = archMapper "sm" cudaCapabilities; | ||
|
||
# virtualArches :: List String | ||
# The virtual architectures are typically used for forward compatibility, when trying to support | ||
# an architecture newer than the CUDA version allows. | ||
# E.g. [ "compute_75" "compute_86" ] | ||
virtualArches = archMapper "compute" cudaCapabilities; | ||
|
||
# arches :: List String | ||
# By default, build for all supported architectures and forward compatibility via a virtual | ||
# architecture for the newest supported architecture. | ||
# E.g. [ "sm_75" "sm_86" "compute_86" ] | ||
arches = realArches ++ | ||
lists.optional enableForwardCompat (lists.last virtualArches); | ||
|
||
# gencode :: List String | ||
# A list of CUDA gencode arguments to pass to NVCC. | ||
# E.g. [ "-gencode=arch=compute_75,code=sm_75" ... "-gencode=arch=compute_86,code=compute_86" ] | ||
gencode = | ||
let | ||
base = gencodeMapper "sm" cudaCapabilities; | ||
forward = gencodeMapper "compute" [ (lists.last cudaCapabilities) ]; | ||
in | ||
base ++ lib.optionals enableForwardCompat forward; | ||
}; | ||
|
||
in | ||
# When changing names or formats: pause, validate, and update the assert | ||
assert (formatCapabilities { cudaCapabilities = [ "7.5" "8.6" ]; }) == { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be more interesting to test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's my opinion that capabilities should be sorted, so I would want the order of the output to be invariant with respect to the order of the input (which should already be sorted). Although, I'd love to hear other views! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way we handle this parameter now, the order is significant. It's our semi-implicit convention that the last element goes into PTX. Maybe the take away is rather that we don't want this to be implicit:) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I think you're right there -- the last capability in the list shouldn't be the one which gets turned into a virtual architecture. Although, I do like the idea of having them ordered so packages can decide what to build for. For example, Magma doesn't support 8.6/8.9, so I can imagine at some point in the future Magma iterating over the list of cuda capabilities to find the greatest lower bound (in Magma's case, 8.0) and building for that architecture. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Left as a TODO |
||
cudaCapabilities = [ "7.5" "8.6" ]; | ||
enableForwardCompat = true; | ||
|
||
archNames = [ "Turing" "Ampere" ]; | ||
realArches = [ "sm_75" "sm_86" ]; | ||
virtualArches = [ "compute_75" "compute_86" ]; | ||
arches = [ "sm_75" "sm_86" "compute_86" ]; | ||
|
||
gencode = [ "-gencode=arch=compute_75,code=sm_75" "-gencode=arch=compute_86,code=sm_86" "-gencode=arch=compute_86,code=compute_86" ]; | ||
}; | ||
{ | ||
inherit | ||
cudaArchNames | ||
cudaArchNameToVersions cudaComputeCapabilityToName | ||
cudaRealArches cudaVirtualArches cudaArches | ||
cudaGencode; | ||
cudaCapabilities = cudaComputeCapabilitiesAndForward; | ||
# formatCapabilities :: { cudaCapabilities: List Capability, cudaForwardCompat: Boolean } -> { ... } | ||
inherit formatCapabilities; | ||
|
||
# cudaArchNameToVersions :: String => String | ||
inherit cudaArchNameToVersions; | ||
|
||
# cudaComputeCapabilityToName :: String => String | ||
inherit cudaComputeCapabilityToName; | ||
|
||
# dropDot :: String -> String | ||
inherit dropDot; | ||
} // formatCapabilities { | ||
SomeoneSerge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cudaCapabilities = config.cudaCapabilities or supportedCapabilities; | ||
enableForwardCompat = config.cudaForwardCompat or true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE:
nvidia/thrust
treats this as a path to the executable, not parent directoryTODO: check if maybe
nvidia/thrust
actually does this right