-
Notifications
You must be signed in to change notification settings - Fork 3
/
create_job_file.sh
executable file
·65 lines (53 loc) · 2.14 KB
/
create_job_file.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
59
60
61
62
63
64
65
#!/bin/bash
dataset_name="$1"
model="$2"
revision="$3"
seeds="$4"
# Determine the GPU memory based on the dataset name and model
if [[ $dataset_name == "swiss_criticality_prediction_citation_"* ]] || [[ $dataset_name == "swiss_law_area_prediction_"* ]]; then
gpu_memory="32"
elif [[ $dataset_name == "swiss_criticality_prediction_bge_"* ]]; then
gpu_memory="48"
else # swiss_judgment_prediction_xl
gpu_memory="80"
fi
# add exceptions
if [[ $dataset_name == "swiss_judgment_prediction_xl_"* ]]; then
gpu_memory="80" # we get a time limit error otherwise
fi
if [[ $model == "microsoft/mdeberta-v3-base" ]] || [[ $model == *"-roberta-large" ]] || [[ $model == *"mt5-"* ]]; then
gpu_memory="80" # we might get a time limit error otherwise
fi
# Replace slashes in the model name with underscores
model_for_path=$(echo "${model}" | tr '/' '_')
# Generate a unique job file name
job_file="jobfiles/${dataset_name}_${model_for_path}_${gpu_memory}.sbatch"
# Create the job file
cat > "${job_file}" << EOL
#!/bin/bash
#SBATCH --job-name=${dataset_name}_${model_for_path}_${gpu_memory}
#SBATCH --output=slurm_logs/${dataset_name}_${model_for_path}_${gpu_memory}.out
#SBATCH --error=slurm_logs/${dataset_name}_${model_for_path}_${gpu_memory}.err
#SBATCH [email protected]
#SBATCH --mail-type=end,fail
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --mem=128GB
#SBATCH --cpus-per-task=4
#SBATCH --time=2-00:00:00
#SBATCH -C GPU_MEM:${gpu_memory}GB
#SBATCH --gpus=1
#SBATCH --partition=owners
#SBATCH --array=${seeds}
# set up the environment
cd /home/users/jniklaus/LEXTREME
conda init bash
conda activate lextreme
export PATH=$PATH:/home/groups/deho/miniconda3/envs/lextreme/bin/python3
export PYTHONPATH=. HF_DATASETS_CACHE=$SCRATCH/cache/datasets/${SLURM_ARRAY_TASK_ID} TRANSFORMERS_CACHE=$SCRATCH/cache/models
# Execute your program with the specified dataset, model, and GPU memory
python3 main.py -t ${dataset_name} -lmt ${model} -rev ${revision} -ld $SCRATCH/swiss_legal_data -gm ${gpu_memory} -los \${SLURM_ARRAY_TASK_ID} -rmo default -dmo reuse_dataset_if_exists
EOL
# Submit the job using sbatch
echo "Submitting job ${job_file}"
sbatch "${job_file}"