Skip to content

Commit a9e9a38

Browse files
authored
Update run_benchmark.sh
1 parent a231251 commit a9e9a38

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

examples/pytorch/diffusion_model/diffusers/framepack/run_benchmark.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,23 @@ function run_benchmark {
8080
dimension_num=${#dimensions[@]}
8181
if [ "${visible_gpus}" -gt "${dimension_num}" ]; then
8282
count=${dimension_num}
83-
step=1
83+
result=("${dimensions[@]}")
8484
else
8585
count=${visible_gpus}
86-
step=$((dimension_num/visible_gpus))
87-
left=${dimensions[@]:step*count-1:dimension_num}
88-
dimensions=("${dimensions[@]:0:step*count-1}" "$left")
86+
remainder=$((dimension_num % visible_gpus))
87+
base_size=$((dimension_num / visible_gpus))
88+
start=0
89+
for ((group=0; group<count; group++)); do
90+
current_size=$((base_size + (group < remainder ? 1 : 0)))
91+
end=$((start + current_size))
92+
current_group="${dimensions[@]:start:end-start}"
93+
if [[ $group -ne 0 ]]; then
94+
result=("${result[@]}" "${current_group}")
95+
else
96+
result=("${current_group}")
97+
fi
98+
start=$end
99+
done
89100
fi
90101

91102
for ((i=0; i<count; i++)); do
@@ -95,7 +106,7 @@ function run_benchmark {
95106
--dataset_location ${dataset_location} \
96107
--ratio ${ratio} \
97108
--limit ${limit} \
98-
--dimension_list ${dimensions[@]:i*step:(i+1)*step} \
109+
--dimension_list ${result[i]} \
99110
${extra_cmd} &
100111
program_pid+=($!)
101112
echo "Start (PID: ${program_pid[-1]}, GPU: ${i})"

0 commit comments

Comments
 (0)