-
-
Notifications
You must be signed in to change notification settings - Fork 14k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #325222 from SomeoneSerge/fix/gpu-access/torch-bin
python3Packages.torch-bin: gpuChecks -> tests.tester-<name>.gpuCheck
- Loading branch information
Showing
4 changed files
with
43 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
pkgs/development/python-modules/torch/mk-runtime-check.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
cudaPackages, | ||
feature, | ||
torch, | ||
versionAttr, | ||
}: | ||
|
||
cudaPackages.writeGpuTestPython | ||
{ | ||
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) | ||
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
{ callPackage }: | ||
{ | ||
callPackage, | ||
torchWithCuda, | ||
torchWithRocm, | ||
}: | ||
|
||
callPackage ./gpu-checks.nix { } | ||
{ | ||
# To perform the runtime check use either | ||
# `nix run .#python3Packages.torch.tests.tester-cudaAvailable` (outside the sandbox), or | ||
# `nix build .#python3Packages.torch.tests.tester-cudaAvailable.gpuCheck` (in a relaxed sandbox) | ||
tester-cudaAvailable = callPackage ./mk-runtime-check.nix { | ||
feature = "cuda"; | ||
versionAttr = "cuda"; | ||
torch = torchWithCuda; | ||
}; | ||
tester-rocmAvailable = callPackage ./mk-runtime-check.nix { | ||
feature = "rocm"; | ||
versionAttr = "hip"; | ||
torch = torchWithRocm; | ||
}; | ||
} |