cudaPackages: updated convention for gpu/runtime checks
Runtime tests (derivations asking for a relaxed sandbox) are now expected at p.gpuCheck, p.gpuChecks.<name>, or at p.tests.<name>.gpuCheck.
This commit is contained in:
@@ -85,7 +85,6 @@ in
|
||||
opengl.paths = config.hardware.opengl.extraPackages ++ [
|
||||
config.hardware.opengl.package
|
||||
pkgs.addOpenGLRunpath.driverLink
|
||||
"/dev/video*"
|
||||
"/dev/dri"
|
||||
];
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
SDL,
|
||||
addOpenGLRunpath,
|
||||
alembic,
|
||||
blender,
|
||||
boost,
|
||||
brotli,
|
||||
callPackage,
|
||||
@@ -372,9 +373,21 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
--render-frame 1
|
||||
done
|
||||
'';
|
||||
|
||||
tester-cudaAvailable = cudaPackages.writeGpuTestPython { } ''
|
||||
import subprocess
|
||||
subprocess.run([${
|
||||
lib.concatMapStringsSep ", " (x: ''"${x}"'') [
|
||||
(lib.getExe (blender.override { cudaSupport = true; }))
|
||||
"--background"
|
||||
"-noaudio"
|
||||
"--python-exit-code"
|
||||
"1"
|
||||
"--python"
|
||||
"${./test-cuda.py}"
|
||||
]
|
||||
}], check=True) # noqa: E501
|
||||
'';
|
||||
};
|
||||
gpuChecks = callPackage ./gpu-checks.nix { };
|
||||
};
|
||||
|
||||
meta = {
|
||||
@@ -383,7 +396,8 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
# They comment two licenses: GPLv2 and Blender License, but they
|
||||
# say: "We've decided to cancel the BL offering for an indefinite period."
|
||||
# OptiX, enabled with cudaSupport, is non-free.
|
||||
license = with lib.licenses; [ gpl2Plus ] ++ lib.optional cudaSupport unfree;
|
||||
license = with lib.licenses; [ gpl2Plus ] ++ lib.optional cudaSupport (unfree // { shortName = "NVidia OptiX EULA"; });
|
||||
|
||||
platforms = [
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
bash,
|
||||
blender,
|
||||
callPackage,
|
||||
lib,
|
||||
runCommand,
|
||||
writeScriptBin,
|
||||
}:
|
||||
|
||||
let
|
||||
blenderWithCuda = blender.override { cudaSupport = true; };
|
||||
name = "${blenderWithCuda.name}-check-cuda";
|
||||
unwrapped = writeScriptBin "${name}-unwrapped" ''
|
||||
#!${lib.getExe bash}
|
||||
${lib.getExe blenderWithCuda} --background -noaudio --python-exit-code 1 --python ${./test-cuda.py}
|
||||
'';
|
||||
in
|
||||
{
|
||||
cudaAvailable = runCommand name {
|
||||
nativeBuildInputs = [ unwrapped ];
|
||||
requiredSystemFeatures = [ "cuda" ];
|
||||
passthru = {
|
||||
inherit unwrapped;
|
||||
};
|
||||
} "${name}-unwrapped && touch $out";
|
||||
}
|
||||
@@ -16,7 +16,6 @@ let
|
||||
cudatoolkit
|
||||
flags
|
||||
libcublas
|
||||
setupCudaHook
|
||||
;
|
||||
inherit (lib) getDev getLib getOutput;
|
||||
fs = lib.fileset;
|
||||
@@ -59,20 +58,19 @@ backendStdenv.mkDerivation {
|
||||
(lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" flags.cmakeCudaArchitecturesString)
|
||||
];
|
||||
|
||||
passthru.gpuChecks.withCuda = saxpy.overrideAttrs (
|
||||
_: {
|
||||
requiredSystemFeatures = ["cuda"];
|
||||
doInstallCheck = true;
|
||||
postInstallCheck = ''
|
||||
$out/bin/saxpy
|
||||
'';
|
||||
}
|
||||
);
|
||||
passthru.gpuCheck = saxpy.overrideAttrs (_: {
|
||||
requiredSystemFeatures = [ "cuda" ];
|
||||
doInstallCheck = true;
|
||||
postInstallCheck = ''
|
||||
$out/bin/${saxpy.meta.mainProgram or (lib.getName saxpy)}
|
||||
'';
|
||||
});
|
||||
|
||||
meta = rec {
|
||||
description = "Simple (Single-precision AX Plus Y) FindCUDAToolkit.cmake example for testing cross-compilation";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = lib.teams.cuda.members;
|
||||
mainProgram = "saxpy";
|
||||
platforms = lib.platforms.unix;
|
||||
badPlatforms = lib.optionals (flags.isJetsonBuild && cudaOlder "11.4") platforms;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
lib,
|
||||
writers,
|
||||
runCommand,
|
||||
}:
|
||||
{
|
||||
feature ? "cuda",
|
||||
name ? feature,
|
||||
libraries ? [ ],
|
||||
}:
|
||||
content:
|
||||
|
||||
let
|
||||
tester = writers.writePython3Bin "tester-${name}" { inherit libraries; } content;
|
||||
tester' = tester.overrideAttrs (oldAttrs: {
|
||||
passthru.gpuCheck =
|
||||
runCommand "test-${name}"
|
||||
{
|
||||
nativeBuildInputs = [ tester' ];
|
||||
requiredSystemFeatures = [ feature ];
|
||||
}
|
||||
''
|
||||
set -e
|
||||
${tester.meta.mainProgram or (lib.getName tester')}
|
||||
touch $out
|
||||
'';
|
||||
});
|
||||
in
|
||||
tester'
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
lib,
|
||||
buildPythonPackage,
|
||||
callPackage,
|
||||
cudaPackages,
|
||||
fetchFromGitHub,
|
||||
substituteAll,
|
||||
pythonOlder,
|
||||
@@ -9,6 +9,7 @@
|
||||
setuptools,
|
||||
pytestCheckHook,
|
||||
versioneer,
|
||||
pynvml,
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
@@ -51,7 +52,12 @@ buildPythonPackage rec {
|
||||
# OSError: /run/opengl-driver/lib/libnvidia-ml.so.1: cannot open shared object file: No such file or directory
|
||||
doCheck = false;
|
||||
|
||||
passthru.gpuChecks.nvmlInit = callPackage ./test-gpu.nix { };
|
||||
passthru.tests.tester-nvmlInit = cudaPackages.writeGpuTestPython { libraries = [ pynvml ]; } ''
|
||||
import pynvml
|
||||
from pynvml.smi import nvidia_smi # noqa: F401
|
||||
|
||||
print(f"{pynvml.nvmlInit()=}")
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Python bindings for the NVIDIA Management Library";
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
{ runCommandNoCC, python }:
|
||||
|
||||
runCommandNoCC "pynvml-gpu-test"
|
||||
{
|
||||
nativeBuildInputs = [ (python.withPackages (ps: [ ps.pynvml ])) ];
|
||||
requiredSystemFeatures = [ "cuda" ];
|
||||
}
|
||||
''
|
||||
python3 << EOF
|
||||
import pynvml
|
||||
from pynvml.smi import nvidia_smi
|
||||
|
||||
pynvml.nvmlInit()
|
||||
EOF
|
||||
|
||||
touch $out
|
||||
''
|
||||
@@ -648,7 +648,7 @@ buildPythonPackage rec {
|
||||
blasProvider = blas.provider;
|
||||
# To help debug when a package is broken due to CUDA support
|
||||
inherit brokenConditions;
|
||||
gpuChecks = callPackage ./gpu-checks.nix { };
|
||||
tests = callPackage ./tests.nix { };
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
lib,
|
||||
callPackage,
|
||||
torchWithCuda,
|
||||
torchWithRocm,
|
||||
callPackage,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -11,38 +11,28 @@ let
|
||||
feature,
|
||||
versionAttr,
|
||||
torch,
|
||||
runCommandNoCC,
|
||||
writers,
|
||||
cudaPackages,
|
||||
}:
|
||||
let
|
||||
name = "${torch.name}-${feature}-check";
|
||||
unwrapped = writers.writePython3Bin "${name}-unwrapped" { libraries = [ torch ]; } ''
|
||||
cudaPackages.writeGpuPythonTest
|
||||
{
|
||||
inherit feature;
|
||||
libraries = [ torch ];
|
||||
name = "${feature}Available";
|
||||
}
|
||||
''
|
||||
import torch
|
||||
message = f"{torch.cuda.is_available()=} and {torch.version.${versionAttr}=}"
|
||||
assert torch.cuda.is_available() and torch.version.${versionAttr}, message
|
||||
print(message)
|
||||
'';
|
||||
in
|
||||
runCommandNoCC name
|
||||
{
|
||||
nativeBuildInputs = [ unwrapped ];
|
||||
requiredSystemFeatures = [ feature ];
|
||||
passthru = {
|
||||
inherit unwrapped;
|
||||
};
|
||||
}
|
||||
''
|
||||
${name}-unwrapped
|
||||
touch $out
|
||||
'';
|
||||
in
|
||||
{
|
||||
cudaAvailable = callPackage accelAvailable {
|
||||
tester-cudaAvailable = callPackage accelAvailable {
|
||||
feature = "cuda";
|
||||
versionAttr = "cuda";
|
||||
torch = torchWithCuda;
|
||||
};
|
||||
rocmAvailable = callPackage accelAvailable {
|
||||
tester-rocmAvailable = callPackage accelAvailable {
|
||||
feature = "rocm";
|
||||
versionAttr = "hip";
|
||||
torch = torchWithRocm;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{ callPackage }:
|
||||
|
||||
callPackage ./gpu-checks.nix { }
|
||||
@@ -77,6 +77,8 @@ let
|
||||
saxpy = final.callPackage ../development/cuda-modules/saxpy { };
|
||||
nccl = final.callPackage ../development/cuda-modules/nccl { };
|
||||
nccl-tests = final.callPackage ../development/cuda-modules/nccl-tests { };
|
||||
|
||||
writeGpuTestPython = final.callPackage ../development/cuda-modules/write-gpu-python-test.nix { };
|
||||
});
|
||||
|
||||
mkVersionedPackageName =
|
||||
|
||||
Reference in New Issue
Block a user