diff options
author | Someone Serge <sergei.kozlukov@aalto.fi> | 2024-01-06 22:50:52 +0000 |
---|---|---|
committer | Someone Serge <sergei.kozlukov@aalto.fi> | 2024-01-10 20:47:34 +0000 |
commit | 231aca2b973e4f82703303fb3d4dce692d0aa4ee (patch) | |
tree | 14da5658a71c2beb014ba2dabe480ea3c43bc906 | |
parent | c76883f955ebf8b6a6a8194febfbcc2f453ac819 (diff) |
apptainer: add a cuda test
(cherry picked from commit 0c4fe1f45241fee18ce1a33d2a8a3dfdba611cbb)
-rw-r--r-- | pkgs/applications/virtualization/singularity/generic.nix | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/pkgs/applications/virtualization/singularity/generic.nix b/pkgs/applications/virtualization/singularity/generic.nix index ab789de0221d9..6fd2905d9d4e9 100644 --- a/pkgs/applications/virtualization/singularity/generic.nix +++ b/pkgs/applications/virtualization/singularity/generic.nix @@ -33,6 +33,7 @@ in , which # Build inputs , bash +, callPackage , conmon , coreutils , cryptsetup @@ -271,5 +272,38 @@ in singularity = finalAttrs.finalPackage; }; }; + gpuChecks = lib.optionalAttrs (projectName == "apptainer") { + # Should be in tests, but Ofborg would skip image-hello-cowsay because + # saxpy is unfree. + image-saxpy = callPackage + ({ singularity-tools, cudaPackages }: + singularity-tools.buildImage { + name = "saxpy"; + contents = [ cudaPackages.saxpy ]; + memSize = 2048; + diskSize = 2048; + singularity = finalAttrs.finalPackage; + }) + { }; + saxpy = + callPackage + ({ runCommand, writeShellScriptBin }: + let + unwrapped = writeShellScriptBin "apptainer-cuda-saxpy" + '' + ${lib.getExe finalAttrs.finalPackage} exec --nv $@ ${finalAttrs.passthru.gpuChecks.image-saxpy} saxpy + ''; + in + runCommand "run-apptainer-cuda-saxpy" + { + requiredSystemFeatures = [ "cuda" ]; + nativeBuildInputs = [ unwrapped ]; + passthru = { inherit unwrapped; }; + } + '' + apptainer-cuda-saxpy + '') + { }; + }; }; }) |