poetry2nix/tests/ml-stack/default.nix

17 lines
731 B
Nix
Raw Normal View History

2023-04-06 15:38:21 -07:00
{ lib, poetry2nix, python3, runCommand }:
let
env = poetry2nix.mkPoetryEnv {
python = python3;
pyproject = ./pyproject.toml;
poetrylock = ./poetry.lock;
preferWheels = true;
};
py = env.python;
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
''