|
#!/bin/bash |
|
|
|
|
|
test_perturbations=("reverse_full") |
|
checkpoints=("checkpoint-500" "checkpoint-1000" "checkpoint-1500" "checkpoint-2000" "checkpoint-2500" "checkpoint-3000" |
|
"checkpoint-3500" "checkpoint-4000" "checkpoint-4500" "checkpoint-5000" "checkpoint-5500" "checkpoint-6000" |
|
"checkpoint-6500" "checkpoint-7000" "checkpoint-7500" "checkpoint-8000" "checkpoint-8500" "checkpoint-9000" |
|
"checkpoint-9500" "checkpoint-10000" "checkpoint-11500") |
|
random_seeds=(1 2 3 4 5) |
|
gpus=(1 2 3 4 5 6 7) |
|
|
|
|
|
task_index=0 |
|
total_combinations=$((${#test_perturbations[@]} * ${#checkpoints[@]} * ${#random_seeds[@]})) |
|
|
|
|
|
is_gpu_free() { |
|
gpu_id=$1 |
|
utilization=$(nvidia-smi -i $gpu_id --query-gpu=utilization.gpu --format=csv,noheader,nounits) |
|
if [ "$utilization" -lt 10 ]; then |
|
return 0 |
|
else |
|
return 1 |
|
fi |
|
} |
|
|
|
|
|
get_next_task() { |
|
perturbation=${test_perturbations[$((task_index % ${#test_perturbations[@]}))]} |
|
checkpoint=${checkpoints[$(((task_index / ${#test_perturbations[@]}) % ${#checkpoints[@]}))]} |
|
seed=${random_seeds[$(((task_index / (${#test_perturbations[@]} * ${#checkpoints[@]})) % ${#random_seeds[@]}))]} |
|
} |
|
|
|
|
|
while [ $task_index -lt $total_combinations ]; do |
|
for gpu in "${gpus[@]}"; do |
|
if is_gpu_free $gpu; then |
|
get_next_task |
|
|
|
echo "Running experiment for $perturbation, $checkpoint, seed $seed on GPU $gpu" |
|
CUDA_VISIBLE_DEVICES=$gpu python perplexities_qwen.py "$perturbation" "$checkpoint" "$seed" & |
|
|
|
|
|
task_index=$((task_index + 1)) |
|
|
|
|
|
if [ $task_index -ge $total_combinations ]; then |
|
break |
|
fi |
|
fi |
|
done |
|
|
|
|
|
wait |
|
sleep 5 |
|
done |