-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
69 lines (67 loc) · 2.2 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{
description = "PyTorch code for deep learning on chest X-rays (CXR)";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
flake-utils.url = "github:numtide/flake-utils";
};
# See https://old.reddit.com/r/Python/comments/npu66t/reproducible_python_environment_with_nix_flake/
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
python = "python310";
pkgs = (import nixpkgs {
inherit system;
config = {
allowUnfree = true;
cudaSupport = true;
};
overlays = [
];
});
# core pkgs are those required to run headless scripts
corePythonPkgs = ps: with ps; [
numpy
pandas
pytorchWithCuda
scikit-learn
scipy
#torchinfo # currently does not build on nix 22.05?? as of 2022-09-29
torchvision
tqdm
];
corePythonEnv = pkgs.${python}.withPackages corePythonPkgs;
jupyterPythonEnv = pkgs.${python}.withPackages (ps: with ps;
((corePythonPkgs ps) ++ [
ipympl # for %matplotlib widget
jupyterlab
matplotlib
# not strictly for jupyter but still useful for development
black
]));
in rec {
packages = {
download = pkgs.stdenv.mkDerivation {
name = "download";
propagatedBuildInputs = with pkgs; [
google-cloud-sdk
./download_mimic_cxr_jpg.sh
];
};
};
apps = rec {
default = jupyter;
jupyter = {
type = "app";
# Note that this is not a full command line; do not include
# arguments. If you would like to provide a command line, see the
# "foo" example further down in this file
program = "${jupyterPythonEnv}/bin/jupyter";
};
download = with pkgs; {
type = "app";
program = "${packages.download}/download_mimic_cxr_jpg.sh";
};
};
devShell = pkgs.mkShell { buildInputs = with pkgs; [ jupyterPythonEnv ]; };
});
}