Files
nixpkgs/pkgs/development/python-modules/torch/tests/mk-runtime-check.nix
2025-05-05 22:19:53 +02:00

20 lines
386 B
Nix

{
cudaPackages,
feature,
libraries,
versionAttr,
}:
cudaPackages.writeGpuTestPython
{
inherit feature;
inherit libraries;
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)
''