diff options
author | Someone Serge <sergei.kozlukov@aalto.fi> | 2024-01-12 00:16:50 +0000 |
---|---|---|
committer | Someone Serge <sergei.kozlukov@aalto.fi> | 2024-01-12 20:24:50 +0000 |
commit | 875e43dfd70a3e58573d94d44e4c931d464ae76a (patch) | |
tree | 1122f80cc41b0876ceca52d72554c7d5f84ade14 /pkgs/development | |
parent | 27b277b63c2c8ab5a0e40e88216f1061a80183d0 (diff) | |
download | nixlib-875e43dfd70a3e58573d94d44e4c931d464ae76a.tar nixlib-875e43dfd70a3e58573d94d44e4c931d464ae76a.tar.gz nixlib-875e43dfd70a3e58573d94d44e4c931d464ae76a.tar.bz2 nixlib-875e43dfd70a3e58573d94d44e4c931d464ae76a.tar.lz nixlib-875e43dfd70a3e58573d94d44e4c931d464ae76a.tar.xz nixlib-875e43dfd70a3e58573d94d44e4c931d464ae76a.tar.zst nixlib-875e43dfd70a3e58573d94d44e4c931d464ae76a.zip |
cudaPackages.cuda{,-library}-samples: move to cuda-modules/
cudaPackages are part of the package set and should not depend on pkgs/test
Diffstat (limited to 'pkgs/development')
4 files changed, 220 insertions, 0 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 000000000000..4cb34af73209 --- /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 000000000000..d4182536654e --- /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 000000000000..d41da90cd5d0 --- /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 000000000000..fb3d7cc99da9 --- /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; + }; + } +) |