-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3-textgen.sh
59 lines (45 loc) · 1.94 KB
/
3-textgen.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
#!/bin/bash
#SBATCH --job-name=textgen
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --time=0-12:00:00
#SBATCH --partition=gpu,xgpu
#SBATCH --gres=gpu:a30:2
#SBATCH --mem=70GB
#SBATCH --output=/home/anthony.li/llm-watermark-adaptive/log/textgen.%A.%a.out
#SBATCH --error=/home/anthony.li/llm-watermark-adaptive/log/textgen.%A.%a.err
#SBATCH --mail-type=ALL
#SBATCH [email protected]
#SBATCH --array=1-30
module purge
module load Python/3.11.5-GCCcore-13.2.0
cd /home/anthony.li/llm-watermark-adaptive
mkdir -p results
mkdir -p log
echo "Starting job with ID ${SLURM_JOB_ID} on ${SLURM_JOB_NODELIST}"
echo $(which python)
export PATH="/home/anthony.li/.local/bin:$PATH"
export PYTHONPATH=".":$PYTHONPATH
export HF_HOME=/scratch/user/anthony.li/hf_cache
# Determine the total number of commands by counting lines in 3-textgen-commands.sh
total_commands=$(wc -l < 3-textgen-commands.sh)
total_jobs=30
# Calculate the number of commands per job (minimum)
commands_per_job=$((total_commands / total_jobs))
# Calculate the number of jobs that need to process an extra command
extra_commands=$((total_commands % total_jobs))
# Determine the start and end command index for this particular job
if [ ${SLURM_ARRAY_TASK_ID} -le $extra_commands ]; then
start_command=$(( (${SLURM_ARRAY_TASK_ID} - 1) * (commands_per_job + 1) + 1 ))
end_command=$(( ${SLURM_ARRAY_TASK_ID} * (commands_per_job + 1) ))
else
start_command=$(( extra_commands * (commands_per_job + 1) + (${SLURM_ARRAY_TASK_ID} - extra_commands - 1) * commands_per_job + 1 ))
end_command=$(( extra_commands * (commands_per_job + 1) + (${SLURM_ARRAY_TASK_ID} - extra_commands) * commands_per_job ))
fi
echo "Running tasks for commands from $start_command to $end_command"
# Loop over the designated commands for this job
for i in $(seq $start_command $end_command); do
command=$(sed -n "${i}p" 3-textgen-commands.sh)
echo "Executing command $i: $command"
eval "$command"
done