Merge pull request #322070 from jeremyschlatter/cmakeCudaArchitecturesString

treewide: use cmakeCudaArchitecturesString
This commit is contained in:
Someone 2024-06-25 11:59:19 +00:00 committed by GitHub
commit 35551ddea8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 15 additions and 32 deletions

View File

@ -24,7 +24,7 @@
assert enableCuda -> singlePrec;
let
inherit (cudaPackages.cudaFlags) cudaCapabilities dropDot;
inherit (cudaPackages.flags) cmakeCudaArchitecturesString;
# Select reasonable defaults for all major platforms
# The possible values are defined in CMakeLists.txt:
@ -111,10 +111,10 @@ in stdenv.mkDerivation rec {
]
) ++ lib.optionals enableCuda [
"-DGMX_GPU=CUDA"
(lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" (builtins.concatStringsSep ";" (map dropDot cudaCapabilities)))
(lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cmakeCudaArchitecturesString)
# Gromacs seems to ignore and override the normal variables, so we add this ad hoc:
(lib.cmakeFeature "GMX_CUDA_TARGET_COMPUTE" (builtins.concatStringsSep ";" (map dropDot cudaCapabilities)))
(lib.cmakeFeature "GMX_CUDA_TARGET_COMPUTE" cmakeCudaArchitecturesString)
];
postInstall = ''

View File

@ -122,12 +122,7 @@ effectiveStdenv.mkDerivation (finalAttrs: {
(cmakeBool "LLAMA_VULKAN" vulkanSupport)
]
++ optionals cudaSupport [
(
with cudaPackages.flags;
cmakeFeature "CMAKE_CUDA_ARCHITECTURES" (
builtins.concatStringsSep ";" (map dropDot cudaCapabilities)
)
)
(cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cudaPackages.flags.cmakeCudaArchitecturesString)
]
++ optionals rocmSupport [
(cmakeFeature "CMAKE_C_COMPILER" "hipcc")

View File

@ -14,10 +14,6 @@
let
effectiveStdenv = if cudaSupport then cudaPackages.backendStdenv else inputs.stdenv;
cudaCapabilities = cudaPackages.cudaFlags.cudaCapabilities;
# E.g. [ "80" "86" "90" ]
cudaArchitectures = (builtins.map cudaPackages.cudaFlags.dropDot cudaCapabilities);
cudaArchitecturesString = lib.strings.concatStringsSep ";" cudaArchitectures;
in
effectiveStdenv.mkDerivation (finalAttrs: {
pname = "fastdeploy-ppocr";
@ -65,7 +61,7 @@ effectiveStdenv.mkDerivation (finalAttrs: {
(lib.cmakeBool "BUILD_SHARED_LIBS" true)
]
++ lib.optionals cudaSupport [
(lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cudaArchitecturesString)
(lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cudaPackages.flags.cmakeCudaArchitecturesString)
];
postInstall = ''

View File

@ -29,10 +29,7 @@ let
stdenv = throw "Use effectiveStdenv instead";
effectiveStdenv = if cudaSupport then cudaPackages.backendStdenv else inputs.stdenv;
cudaCapabilities = cudaPackages.cudaFlags.cudaCapabilities;
# E.g. [ "80" "86" "90" ]
cudaArchitectures = (builtins.map cudaPackages.cudaFlags.dropDot cudaCapabilities);
cudaArchitecturesString = lib.strings.concatStringsSep ";" cudaArchitectures;
cudaArchitecturesString = cudaPackages.flags.cmakeCudaArchitecturesString;
howard-hinnant-date = fetchFromGitHub {
owner = "HowardHinnant";

View File

@ -29,8 +29,7 @@ let
pname = "faiss";
version = "1.7.4";
inherit (cudaPackages) cudaFlags backendStdenv;
inherit (cudaFlags) cudaCapabilities dropDot;
inherit (cudaPackages) flags backendStdenv;
stdenv = if cudaSupport then backendStdenv else inputs.stdenv;
@ -93,7 +92,7 @@ stdenv.mkDerivation {
"-DFAISS_ENABLE_PYTHON=${if pythonSupport then "ON" else "OFF"}"
"-DFAISS_OPT_LEVEL=${optLevel}"
] ++ lib.optionals cudaSupport [
"-DCMAKE_CUDA_ARCHITECTURES=${builtins.concatStringsSep ";" (map dropDot cudaCapabilities)}"
"-DCMAKE_CUDA_ARCHITECTURES=${flags.cmakeCudaArchitecturesString}"
"-DCUDAToolkit_INCLUDE_DIR=${cudaJoined}/include"
];

View File

@ -41,8 +41,7 @@ let
then cudaPackages_11
else cudaPackages;
inherit (effectiveCudaPackages) cudaAtLeast cudaFlags cudaOlder;
inherit (cudaFlags) cudaCapabilities;
inherit (effectiveCudaPackages) cudaAtLeast flags cudaOlder;
# move to newer ROCm version once supported
rocmPackages = rocmPackages_5;
@ -52,7 +51,7 @@ let
# lists.subtractLists a b = b - a
# For ROCm
# NOTE: The hip.gpuTargets are prefixed with "gfx" instead of "sm" like cudaFlags.realArches.
# NOTE: The hip.gpuTargets are prefixed with "gfx" instead of "sm" like flags.realArches.
# For some reason, Magma's CMakeLists.txt file does not handle the "gfx" prefix, so we must
# remove it.
rocmArches = lists.map (x: strings.removePrefix "gfx" x) rocmPackages.clr.gpuTargets;
@ -83,12 +82,11 @@ let
throw "No GPU targets specified"
);
# E.g. [ "80" "86" "90" ]
cudaArchitectures = (builtins.map cudaFlags.dropDot cudaCapabilities);
cudaArchitecturesString = strings.concatStringsSep ";" cudaArchitectures;
cudaArchitecturesString = flags.cmakeCudaArchitecturesString;
minArch =
let
# E.g. [ "80" "86" "90" ]
cudaArchitectures = (builtins.map flags.dropDot flags.cudaCapabilities);
minArch' = builtins.head (builtins.sort strings.versionOlder cudaArchitectures);
in
# "75" -> "750" Cf. https://bitbucket.org/icl/magma/src/f4ec79e2c13a2347eff8a77a3be6f83bc2daec20/CMakeLists.txt#lines-273

View File

@ -11,7 +11,7 @@
which,
}: let
inherit (lib) lists strings;
inherit (cudaPackages) backendStdenv cudaFlags;
inherit (cudaPackages) backendStdenv flags;
cuda-common-redist = with cudaPackages; [
cuda_cudart.dev # cuda_runtime.h
@ -89,9 +89,7 @@ in
doCheck = false;
preConfigure = ''
export TCNN_CUDA_ARCHITECTURES="${
strings.concatStringsSep ";" (lists.map cudaFlags.dropDot cudaFlags.cudaCapabilities)
}"
export TCNN_CUDA_ARCHITECTURES="${flags.cmakeCudaArchitecturesString}"
export CUDA_HOME="${cuda-native-redist}"
export LIBRARY_PATH="${cuda-native-redist}/lib/stubs:$LIBRARY_PATH"
export CC="${backendStdenv.cc}/bin/cc"