diff options
author | Someone <sergei.kozlukov@aalto.fi> | 2024-01-15 14:31:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-15 14:31:08 +0000 |
commit | 447236a22f15db0286a6a9b0f9c2c74123f8bbba (patch) | |
tree | fdc7b6d1added0fcd44b30fd1f6d96915a1b7df4 /pkgs/development | |
parent | fe3649c55756508577e8308db0f5542071597714 (diff) | |
parent | 18b114d8bf40e26c86e3d2eadc4df1e5e3fcfb0d (diff) |
Merge pull request #280386 from SomeoneSerge/fix/tests.cuda
tests.cuda: inherit the ready cudaPackages_XX.cuda-samples
Diffstat (limited to 'pkgs/development')
6 files changed, 232 insertions, 5 deletions
diff --git a/pkgs/development/cuda-modules/cuda-library-samples/extension.nix b/pkgs/development/cuda-modules/cuda-library-samples/extension.nix new file mode 100644 index 0000000000000..4cb34af732095 --- /dev/null +++ b/pkgs/development/cuda-modules/cuda-library-samples/extension.nix @@ -0,0 +1,14 @@ +{hostPlatform, lib}: +let + # Samples are built around the CUDA Toolkit, which is not available for + # aarch64. Check for both CUDA version and platform. + platformIsSupported = hostPlatform.isx86_64 && hostPlatform.isLinux; + + # Build our extension + extension = + final: _: + lib.attrsets.optionalAttrs platformIsSupported { + cuda-library-samples = final.callPackage ./generic.nix {}; + }; +in +extension diff --git a/pkgs/development/cuda-modules/cuda-library-samples/generic.nix b/pkgs/development/cuda-modules/cuda-library-samples/generic.nix new file mode 100644 index 0000000000000..d4182536654e1 --- /dev/null +++ b/pkgs/development/cuda-modules/cuda-library-samples/generic.nix @@ -0,0 +1,85 @@ +{ + lib, + backendStdenv, + fetchFromGitHub, + cmake, + addOpenGLRunpath, + cudatoolkit, + cutensor, +}: + +let + rev = "5aab680905d853bce0dbad4c488e4f7e9f7b2302"; + src = fetchFromGitHub { + owner = "NVIDIA"; + repo = "CUDALibrarySamples"; + inherit rev; + sha256 = "0gwgbkq05ygrfgg5hk07lmap7n7ampxv0ha1axrv8qb748ph81xs"; + }; + commonAttrs = { + version = lib.strings.substring 0 7 rev + "-" + lib.versions.majorMinor cudatoolkit.version; + nativeBuildInputs = [ + cmake + addOpenGLRunpath + ]; + buildInputs = [cudatoolkit]; + postFixup = '' + for exe in $out/bin/*; do + addOpenGLRunpath $exe + done + ''; + meta = { + description = "examples of using libraries using CUDA"; + longDescription = '' + CUDA Library Samples contains examples demonstrating the use of + features in the math and image processing libraries cuBLAS, cuTENSOR, + cuSPARSE, cuSOLVER, cuFFT, cuRAND, NPP and nvJPEG. + ''; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [obsidian-systems-maintenance] ++ lib.teams.cuda.members; + }; + }; +in + +{ + cublas = backendStdenv.mkDerivation ( + commonAttrs + // { + pname = "cuda-library-samples-cublas"; + + src = "${src}/cuBLASLt"; + } + ); + + cusolver = backendStdenv.mkDerivation ( + commonAttrs + // { + pname = "cuda-library-samples-cusolver"; + + src = "${src}/cuSOLVER"; + + sourceRoot = "cuSOLVER/gesv"; + } + ); + + cutensor = backendStdenv.mkDerivation ( + commonAttrs + // { + pname = "cuda-library-samples-cutensor"; + + src = "${src}/cuTENSOR"; + + buildInputs = [cutensor]; + + cmakeFlags = ["-DCUTENSOR_EXAMPLE_BINARY_INSTALL_DIR=${builtins.placeholder "out"}/bin"]; + + # CUTENSOR_ROOT is double escaped + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace "\''${CUTENSOR_ROOT}/include" "${cutensor.dev}/include" + ''; + + CUTENSOR_ROOT = cutensor; + } + ); +} diff --git a/pkgs/development/cuda-modules/cuda-samples/extension.nix b/pkgs/development/cuda-modules/cuda-samples/extension.nix new file mode 100644 index 0000000000000..d41da90cd5d0e --- /dev/null +++ b/pkgs/development/cuda-modules/cuda-samples/extension.nix @@ -0,0 +1,42 @@ +{ + cudaVersion, + hostPlatform, + lib, +}: +let + cudaVersionToHash = { + "10.0" = "sha256-XAI6iiPpDVbZtFoRaP1s6VKpu9aV3bwOqqkw33QncP8="; + "10.1" = "sha256-DY8E2FKCFj27jPgQEB1qE9HcLn7CfSiVGdFm+yFQE+k="; + "10.2" = "sha256-JDW4i7rC2MwIRvKRmUd6UyJZI9bWNHqZijrB962N4QY="; + "11.0" = "sha256-BRwQuUvJEVi1mTbVtGODH8Obt7rXFfq6eLH9wxCTe9g="; + "11.1" = "sha256-kM8gFItBaTpkoT34vercmQky9qTFtsXjXMGjCMrsUc4="; + "11.2" = "sha256-gX6V98dRwdAQIsvru2byDLiMswCW2lrHSBSJutyWONw="; + "11.3" = "sha256-34MdMFS2cufNbZVixFdSUDFfLeuKIGFwLBL9d81acU0="; + "11.4" = "sha256-Ewu+Qk6GtGXC37CCn1ZXHc0MQAuyXCGf3J6T4cucTSA="; + "11.5" = "sha256-AKRZbke0K59lakhTi8dX2cR2aBuWPZkiQxyKaZTvHrI="; + "11.6" = "sha256-AsLNmAplfuQbXg9zt09tXAuFJ524EtTYsQuUlV1tPkE="; + # The tag 11.7 of cuda-samples does not exist + "11.8" = "sha256-7+1P8+wqTKUGbCUBXGMDO9PkxYr2+PLDx9W2hXtXbuc="; + "12.0" = "sha256-Lj2kbdVFrJo5xPYPMiE4BS7Z8gpU5JLKXVJhZABUe/g="; + "12.1" = "sha256-xE0luOMq46zVsIEWwK4xjLs7NorcTIi9gbfZPVjIlqo="; + "12.2" = "sha256-pOy0qfDjA/Nr0T9PNKKefK/63gQnJV2MQsN2g3S2yng="; + "12.3" = "sha256-fjVp0G6uRCWxsfe+gOwWTN+esZfk0O5uxS623u0REAk="; + }; + + # Samples are built around the CUDA Toolkit, which is not available for + # aarch64. Check for both CUDA version and platform. + cudaVersionIsSupported = cudaVersionToHash ? ${cudaVersion}; + platformIsSupported = hostPlatform.isx86_64; + isSupported = cudaVersionIsSupported && platformIsSupported; + + # Build our extension + extension = + final: _: + lib.attrsets.optionalAttrs isSupported { + cuda-samples = final.callPackage ./generic.nix { + inherit cudaVersion; + hash = cudaVersionToHash.${cudaVersion}; + }; + }; +in +extension diff --git a/pkgs/development/cuda-modules/cuda-samples/generic.nix b/pkgs/development/cuda-modules/cuda-samples/generic.nix new file mode 100644 index 0000000000000..fb3d7cc99da95 --- /dev/null +++ b/pkgs/development/cuda-modules/cuda-samples/generic.nix @@ -0,0 +1,79 @@ +{ + autoAddOpenGLRunpathHook, + backendStdenv, + cmake, + cudatoolkit, + cudaVersion, + fetchFromGitHub, + fetchpatch, + freeimage, + glfw3, + hash, + lib, + pkg-config, +}: +let + inherit (lib) lists strings; +in +backendStdenv.mkDerivation ( + finalAttrs: { + strictDeps = true; + + pname = "cuda-samples"; + version = cudaVersion; + + src = fetchFromGitHub { + owner = "NVIDIA"; + repo = finalAttrs.pname; + rev = "v${finalAttrs.version}"; + inherit hash; + }; + + nativeBuildInputs = + [ + autoAddOpenGLRunpathHook + pkg-config + ] + # CMake has to run as a native, build-time dependency for libNVVM samples. + # However, it's not the primary build tool -- that's still make. + # As such, we disable CMake's build system. + ++ lists.optionals (strings.versionAtLeast finalAttrs.version "12.2") [cmake]; + + dontUseCmakeConfigure = true; + + buildInputs = [ + cudatoolkit + freeimage + glfw3 + ]; + + # See https://github.com/NVIDIA/cuda-samples/issues/75. + patches = lib.optionals (finalAttrs.version == "11.3") [ + (fetchpatch { + url = "https://github.com/NVIDIA/cuda-samples/commit/5c3ec60faeb7a3c4ad9372c99114d7bb922fda8d.patch"; + hash = "sha256-0XxdmNK9MPpHwv8+qECJTvXGlFxc+fIbta4ynYprfpU="; + }) + ]; + + enableParallelBuilding = true; + + preConfigure = '' + export CUDA_PATH=${cudatoolkit} + ''; + + installPhase = '' + runHook preInstall + + install -Dm755 -t $out/bin bin/${backendStdenv.hostPlatform.parsed.cpu.name}/${backendStdenv.hostPlatform.parsed.kernel.name}/release/* + + runHook postInstall + ''; + + meta = { + description = "Samples for CUDA Developers which demonstrates features in CUDA Toolkit"; + # CUDA itself is proprietary, but these sample apps are not. + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [obsidian-systems-maintenance] ++ lib.teams.cuda.members; + }; + } +) diff --git a/pkgs/development/cuda-modules/saxpy/default.nix b/pkgs/development/cuda-modules/saxpy/default.nix index 9c6692cb0b313..68c60e2d84464 100644 --- a/pkgs/development/cuda-modules/saxpy/default.nix +++ b/pkgs/development/cuda-modules/saxpy/default.nix @@ -16,6 +16,7 @@ let libcublas setupCudaHook ; + inherit (lib) getDev getLib getOutput; in backendStdenv.mkDerivation { pname = "saxpy"; @@ -36,9 +37,9 @@ backendStdenv.mkDerivation { buildInputs = lib.optionals (lib.versionOlder cudaVersion "11.4") [cudatoolkit] ++ lib.optionals (lib.versionAtLeast cudaVersion "11.4") [ - libcublas.dev - libcublas.lib - libcublas.static + (getDev libcublas) + (getLib libcublas) + (getOutput "static" libcublas) cuda_cudart ] ++ lib.optionals (lib.versionAtLeast cudaVersion "12.0") [cuda_cccl]; @@ -50,10 +51,11 @@ backendStdenv.mkDerivation { )) ]; - meta = { + meta = rec { description = "A simple (Single-precision AX Plus Y) FindCUDAToolkit.cmake example for testing cross-compilation"; license = lib.licenses.mit; maintainers = lib.teams.cuda.members; platforms = lib.platforms.unix; + badPlatforms = lib.optionals flags.isJetsonBuild platforms; }; } diff --git a/pkgs/development/cuda-modules/setup-hooks/extension.nix b/pkgs/development/cuda-modules/setup-hooks/extension.nix index 10f126bc12fbf..5141bc9717f93 100644 --- a/pkgs/development/cuda-modules/setup-hooks/extension.nix +++ b/pkgs/development/cuda-modules/setup-hooks/extension.nix @@ -53,7 +53,7 @@ final: _: { autoAddCudaCompatRunpathHook = final.callPackage ( - {makeSetupHook, cuda_compat ? throw "autoAddCudaCompatRunpathHook: No cuda_compat for CUDA ${final.cudaMajorMinorVersion}" }: + {makeSetupHook, cuda_compat ? null }: makeSetupHook { name = "auto-add-cuda-compat-runpath-hook"; @@ -61,7 +61,12 @@ final: _: { # Hotfix Ofborg evaluation libcudaPath = if final.flags.isJetsonBuild then "${cuda_compat}/compat" else null; }; + meta.broken = !final.flags.isJetsonBuild; + + # Pre-cuda_compat CUDA release: + meta.badPlatforms = final.lib.optionals (cuda_compat == null) final.lib.platforms.all; + meta.platforms = cuda_compat.platforms or [ ]; } ./auto-add-cuda-compat-runpath.sh ) |