forked from PytorchConnectomics/pytorch_connectomics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
170 lines (142 loc) · 7.43 KB
/
Copy pathjustfile
File metadata and controls
170 lines (142 loc) · 7.43 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# justfile for PyTorch Connectomics
# Run with: just <command>
# Default recipe to display available commands
default:
@just --list
# ============================================================================
# Setup & Data
# ============================================================================
# Setup SLURM environment: detect CUDA/cuDNN and install PyTorch with correct versions
setup-slurm:
bash scripts/setup_slurm.sh
# Download dataset(s) (e.g., just download lucchi++, just download all)
# Available: lucchi++, snemi, mitoem, cremi
download +datasets:
python scripts/download_data.py {{datasets}}
# List available datasets
download-list:
python scripts/download_data.py --list
# ============================================================================
# Training Commands
# ============================================================================
# Train (e.g., just train fiber, just train lucchi++ -- system.training.num_gpus=1)
# Uses architecture specified in tutorials/{{dataset}}.yaml
train dataset *ARGS='':
python scripts/main.py --config tutorials/{{dataset}}.yaml {{ARGS}}
# Resume training (e.g., just resume fiber ckpt.pt)
resume dataset ckpt *ARGS='':
python scripts/main.py --config tutorials/{{dataset}}.yaml --checkpoint {{ckpt}} {{ARGS}}
# Test model (e.g., just test fiber ckpt.pt)
test dataset ckpt *ARGS='':
python scripts/main.py --config tutorials/{{dataset}}.yaml --mode test --checkpoint {{ckpt}} {{ARGS}}
# Tune decoding parameters on validation set (e.g., just tune fiber ckpt.pt)
tune dataset ckpt *ARGS='':
python scripts/main.py --config tutorials/{{dataset}}.yaml --mode tune --checkpoint {{ckpt}} {{ARGS}}
# Tune parameters then test (recommended for optimal results)
tune-test dataset ckpt *ARGS='':
python scripts/main.py --config tutorials/{{dataset}}.yaml --mode tune-test --checkpoint {{ckpt}} {{ARGS}}
# Quick tuning with 20 trials (for testing)
tune-quick dataset ckpt *ARGS='':
python scripts/main.py --config tutorials/{{dataset}}.yaml --mode tune --checkpoint {{ckpt}} --tune-trials 20 {{ARGS}}
# Test with specific parameter file
test-with-params dataset ckpt params *ARGS='':
python scripts/main.py --config tutorials/{{dataset}}.yaml --mode test --checkpoint {{ckpt}} --params {{params}} {{ARGS}}
# Inference (alias for test, clearer naming)
infer dataset ckpt *ARGS='':
python scripts/main.py --config tutorials/{{dataset}}.yaml --mode infer --checkpoint {{ckpt}} {{ARGS}}
# Train CellMap models (e.g., just train-cellmap cos7)
train-cellmap dataset *ARGS='':
python scripts/cellmap/train_cellmap.py --config tutorials/cellmap_{{dataset}}.yaml {{ARGS}}
# ============================================================================
# Monitoring Commands
# ============================================================================
# Launch TensorBoard for a specific experiment (e.g., just tensorboard lucchi_monai_unet)
# Shows all runs (timestamped directories) for comparison
# Usage: just tensorboard experiment [port] (default port: 6006)
tensorboard experiment port='6006':
tensorboard --logdir outputs/{{experiment}} --port {{port}}
# Launch TensorBoard for all experiments
# Usage: just tensorboard-all [port] (default port: 6006)
tensorboard-all port='6006':
tensorboard --logdir outputs/ --port {{port}}
# Launch TensorBoard for a specific run (e.g., just tensorboard-run lucchi_monai_unet 20250203_143052)
# Usage: just tensorboard-run experiment timestamp [port] (default port: 6006)
tensorboard-run experiment timestamp port='6006':
tensorboard --logdir outputs/{{experiment}}/{{timestamp}} --port {{port}}
# Launch a command on SLURM (command is run exactly as provided).
# Examples:
# just slurm long 8 4 "just train mito_mitoEM_H" vr40g
# just slurm short 8 4 "python scripts/main.py --config tutorials/lucchi.yaml"
# just slurm short 8 4 "just train lucchi++" "" "64G" # override memory
# Time limits: short=12h, medium=2d, long=5d
slurm partition num_cpu num_gpu cmd constraint='' mem='32G':
#!/usr/bin/env bash
constraint_flag=""
if [ -n "{{constraint}}" ]; then
constraint_flag="--constraint={{constraint}}"
fi
# Set time limit to partition maximum
time_limit=$(sinfo -p {{partition}} -h -o "%l" | head -1)
if [ -z "$time_limit" ] || [ "$time_limit" = "infinite" ]; then
case "{{partition}}" in
short|interactive)
time_limit="12:00:00"
;;
medium)
time_limit="2-00:00:00"
;;
long)
time_limit="5-00:00:00"
;;
*)
time_limit="7-00:00:00"
;;
esac
fi
# Run the command exactly as provided (no auto "just" wrapping).
sbatch --job-name="pytc_{{cmd}}" \
--partition={{partition}} \
--output=slurm_outputs/slurm-%j.out \
--error=slurm_outputs/slurm-%j.err \
--nodes=1 \
--ntasks={{num_gpu}} \
--gpus-per-node={{num_gpu}} \
--cpus-per-task={{num_cpu}} \
--mem={{mem}} \
--time=$time_limit \
$constraint_flag \
--wrap="mkdir -p \$HOME/.just && export JUST_TEMPDIR=\$HOME/.just TMPDIR=\$HOME/.just && source /projects/weilab/weidf/lib/miniconda3/bin/activate pytc && cd $PWD && srun --ntasks={{num_gpu}} --ntasks-per-node={{num_gpu}} {{cmd}}"
# Alias for slurm (kept for backward compatibility)
slurm-sh partition num_cpu num_gpu cmd constraint='' mem='32G':
just slurm {{partition}} {{num_cpu}} {{num_gpu}} {{cmd}} {{constraint}} {{mem}}
# Launch parameter sweep from config (e.g., just sweep tutorials/sweep_example.yaml)
sweep config:
python scripts/slurm_launcher.py --config {{config}}
# ============================================================================
# Visualization Commands
# ============================================================================
# Visualize volumes with Neuroglancer from config (e.g., just visualize tutorials/monai_lucchi.yaml test --volumes prediction:path.h5)
# Port defaults to 9999. Override with: just visualize config mode --port 8080 --volumes ...
# Default selects first file from globs. Use --select to change: --select 1, --select filename, --select all
visualize config mode *ARGS='':
#!/usr/bin/env bash
args="--config {{config}} --mode {{mode}}"
# Check if --port is in ARGS, otherwise add default
if [[ ! "{{ARGS}}" =~ --port ]]; then
args="$args --port 9999"
fi
python -i scripts/visualize_neuroglancer.py $args {{ARGS}}
# Visualize specific image and label files (e.g., just visualize-files datasets/img.tif datasets/label.h5)
# If image and label are not provided (empty), no volumes will be loaded
visualize-files image='' label='' port='9999' *ARGS='':
#!/usr/bin/env bash
args="--port {{port}}"
[[ -n "{{image}}" ]] && args="$args --image {{image}}"
[[ -n "{{label}}" ]] && args="$args --label {{label}}"
python -i scripts/visualize_neuroglancer.py $args {{ARGS}}
# Visualize multiple volumes with custom names (e.g., just visualize-volumes image:path/img.tif label:path/lbl.h5)
visualize-volumes +volumes:
python -i scripts/visualize_neuroglancer.py --volumes {{volumes}}
# Visualize with remote access (use 0.0.0.0 for public IP, e.g., just visualize-remote 8080 tutorials/monai_lucchi.yaml)
visualize-remote port config *ARGS='':
python -i scripts/visualize_neuroglancer.py --config {{config}} --ip 0.0.0.0 --port {{port}} {{ARGS}}