-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlanguagebinb_multigpu.sh
executable file
·47 lines (38 loc) · 1.15 KB
/
languagebinb_multigpu.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
#!/bin/bash
dataset="datasets/imagenet/ILSVRC2012_img_val"
eval_list="datasets/imagenet/val_languagebind_5k_true.txt"
lambda1=0
lambda2=0.05
lambda3=1
lambda4=1
declare -a cuda_devices=("0" "1")
# GPU numbers
gpu_numbers=${#cuda_devices[@]}
echo "The number of GPUs is $gpu_numbers."
# text length
line_count=$(wc -l < "$eval_list")
echo "Evaluation on $line_count instances."
line_count_per_gpu=$(( (line_count + gpu_numbers - 1) / gpu_numbers ))
echo "Each GPU should process at least $line_count_per_gpu lines."
gpu_index=0
for device in "${cuda_devices[@]}"
do
begin=$((gpu_index * line_count_per_gpu))
if [ $gpu_index -eq $((gpu_numbers - 1)) ]; then
end=-1 # 最后一个 GPU,设置 end 为 -1
else
end=$((begin + line_count_per_gpu))
fi
CUDA_VISIBLE_DEVICES=$device python -m submodular_attribution.smdl_explanation_imagenet_languagebind_superpixel \
--Datasets $dataset \
--eval-list $eval_list \
--lambda1 $lambda1 \
--lambda2 $lambda2 \
--lambda3 $lambda3 \
--lambda4 $lambda4 \
--begin $begin \
--end $end &
gpu_index=$((gpu_index + 1))
done
wait
echo "All processes have completed."