2023-10-26 12:18:24 +13:00
|
|
|
{ poetry2nix, python310, runCommand }:
|
2023-04-06 15:38:21 -07:00
|
|
|
let
|
|
|
|
env = poetry2nix.mkPoetryEnv {
|
2023-10-25 14:31:13 -04:00
|
|
|
python = python310;
|
2023-04-06 15:38:21 -07:00
|
|
|
pyproject = ./pyproject.toml;
|
|
|
|
poetrylock = ./poetry.lock;
|
|
|
|
preferWheels = true;
|
|
|
|
};
|
2023-04-06 17:19:04 -07:00
|
|
|
in
|
2023-04-06 16:44:31 -07:00
|
|
|
# Note: torch.cuda() will print False, even if you have a GPU, when this runs *during test.*
|
2023-04-06 17:19:04 -07:00
|
|
|
# But if you run the script below in your shell (rather than during build), it will print True.
|
|
|
|
# Presumably this is due to sandboxing.
|
2023-04-06 16:44:31 -07:00
|
|
|
runCommand "ml-stack-test" { } ''
|
2023-04-06 17:18:01 -07:00
|
|
|
${env}/bin/python -c 'import torch; import torchvision; print(torch.__version__); print(torchvision.__version__); print(torch.cuda.is_available()); x = torch.randn(3,3); x = x.cuda() if torch.cuda.is_available() else x; print(x**2)' > $out
|
2023-04-06 17:19:04 -07:00
|
|
|
''
|