blender: add CUDA discovery test

This commit is contained in:
Someone Serge 2023-10-16 21:59:59 +03:00
parent 340b41815d
commit b9299696ab
2 changed files with 18 additions and 0 deletions

View File

@ -372,6 +372,16 @@ stdenv.mkDerivation (finalAttrs: {
--render-frame 1
done
'';
cudaAvailable = runCommand
"blender-cuda-available"
{
nativeBuildInputs = [ finalAttrs.finalPackage ];
requiredSystemFeatures = [ "cuda" ];
}
''
blender --background -noaudio --python-exit-code 1 --python ${./test-cuda.py} && touch $out
'';
};
};

View File

@ -0,0 +1,8 @@
import bpy
preferences = bpy.context.preferences.addons["cycles"].preferences
devices = preferences.get_devices_for_type("CUDA")
ids = [d.id for d in devices]
assert any("CUDA" in i for i in ids), f"CUDA not present in {ids}"
print("CUDA is available")