From 0d550ea15618885df4153d733d525b901e7af05d Mon Sep 17 00:00:00 2001 From: qingqing01 Date: Wed, 31 Jan 2018 19:27:44 +0800 Subject: [PATCH] Make parallel tests bind to different GPU. --- paddle/scripts/docker/test.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 paddle/scripts/docker/test.sh diff --git a/paddle/scripts/docker/test.sh b/paddle/scripts/docker/test.sh new file mode 100755 index 00000000000..8180737a8f4 --- /dev/null +++ b/paddle/scripts/docker/test.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +# the number of process to run tests +NUM_PROC=6 + +# calculate and set the memory usage for each process +MEM_USAGE=$(printf "%.2f" `echo "scale=5; 1.0 / $NUM_PROC" | bc`) +export FLAGS_fraction_of_gpu_memory_to_use=$MEM_USAGE + +# get the CUDA device count +CUDA_DEVICE_COUNT=$(nvidia-smi -L | wc -l) + +for (( i = 0; i < $NUM_PROC; i++ )); do + cuda_list=() + for (( j = 0; j < $CUDA_DEVICE_COUNT; j++ )); do + s=$[i+j] + n=$[s%CUDA_DEVICE_COUNT] + if [ $j -eq 0 ]; then + cuda_list=("$n") + else + cuda_list="$cuda_list,$n" + fi + done + echo $cuda_list + # CUDA_VISIBLE_DEVICES http://acceleware.com/blog/cudavisibledevices-masking-gpus + # ctest -I https://cmake.org/cmake/help/v3.0/manual/ctest.1.html?highlight=ctest + env CUDA_VISIBLE_DEVICES=$cuda_list ctest -I $i,,$NUM_PROC --output-on-failure & +done +wait -- GitLab