-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssl_pretraining_slurm_launch_loop.sh
executable file
·58 lines (45 loc) · 1.68 KB
/
ssl_pretraining_slurm_launch_loop.sh
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
#!/bin/bash
# Help function.
function display_help {
echo "Usage: $0 EXPERIMENT"
echo "Arguments:"
echo " EXPERIMENT Type of experiment to carry out ('RayTune', 'DDP', 'Imbalanced', or 'Balanced')"
echo " -h, --help Display this help message"
exit 0
}
# Parse and check the first argument.
experiment=$1
if [[ $1 == "-h" || $1 == "--help" ]]; then
display_help
elif [[ -z $experiment ]]; then
echo "Error: Selecting a type of experiment is required."
display_help
elif [[ $experiment != "RayTune" && $experiment != "DDP" && $experiment != "Imbalanced" && $experiment != "Balanced" ]]; then
echo "Error: Invalid type of experiment. Supported ones are 'RayTune', 'DDP', 'Imbalanced', and 'Balanced'."
display_help
else
echo "Experiment: $experiment"
fi
# Define the variables.
models=("BarlowTwins" "MoCov2" "SimCLR" "SimCLRv2" "SimSiam")
backbones=("resnet18") # "resnet50"
# Loop over the sbatch commands.
for m in "${models[@]}"; do
for b in "${backbones[@]}"; do
# Check if continue.
read -p "Launch job with ${m} and ${b}? ('yes'/enter to launch, 'no' to continue, and 'exit' to leave): " input
while [[ -n $input && $input != "yes" && $input != "no" && $input != "exit" ]]; do
read -p "Invalid input. Please type 'yes'/enter, 'no', or 'exit': " input
done
if [[ $input == "no" || $input == "exit" ]]; then
break
fi
# Run.
command="sbatch -J ${m}_${b}_${experiment} -o out_${m}_${b}_${experiment}.out ssl_pretraining_slurm.sh ${m} ${b} ${experiment}"
echo ${command}
${command}
done
if [[ $input == "exit" ]]; then
break
fi
done