diff --git a/paddle/fluid/inference/api/CMakeLists.txt b/paddle/fluid/inference/api/CMakeLists.txt index 882bb3468388e794e975d87de73537ac41f17cf7..a73f160dfcfe93ed27cf1cf36acc708d4856511e 100644 --- a/paddle/fluid/inference/api/CMakeLists.txt +++ b/paddle/fluid/inference/api/CMakeLists.txt @@ -56,6 +56,7 @@ if(WITH_TESTING) inference_base_test(test_api_impl SRCS api_impl_tester.cc DEPS ${inference_deps} ARGS --word2vec_dirname=${WORD2VEC_MODEL_DIR} --book_dirname=${PYTHON_TESTS_DIR}/book) set_tests_properties(test_api_impl PROPERTIES DEPENDS test_image_classification) + set_tests_properties(test_api_impl PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE") endif() cc_test(test_analysis_predictor SRCS analysis_predictor_tester.cc DEPS analysis_predictor benchmark ${inference_deps} ARGS --dirname=${WORD2VEC_MODEL_DIR}) diff --git a/paddle/fluid/inference/tests/book/CMakeLists.txt b/paddle/fluid/inference/tests/book/CMakeLists.txt index 977155440df5294216382cff1c67c2aaca1f546d..aa8828c43294dac94156a9d1c360415d7b9213d0 100644 --- a/paddle/fluid/inference/tests/book/CMakeLists.txt +++ b/paddle/fluid/inference/tests/book/CMakeLists.txt @@ -19,7 +19,9 @@ function(inference_test TARGET_NAME) DEPS paddle_fluid_origin ARGS --dirname=${PYTHON_TESTS_DIR}/book/${TARGET_NAME}${arg}.inference.model) set_tests_properties(test_inference_${TARGET_NAME}${arg} - PROPERTIES DEPENDS test_${TARGET_NAME}) + PROPERTIES DEPENDS test_${TARGET_NAME}) + set_tests_properties(test_inference_${TARGET_NAME}${arg} + PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE") endforeach() endfunction(inference_test) @@ -45,3 +47,4 @@ cc_test(test_inference_nlp DEPS paddle_fluid_origin ARGS --model_path=${PADDLE_BINARY_DIR}/python/paddle/fluid/tests/book/recognize_digits_mlp.inference.model) +set_tests_properties(test_inference_nlp PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE") diff --git a/paddle/fluid/train/CMakeLists.txt b/paddle/fluid/train/CMakeLists.txt index fae28fcb4c3102240438b62c203c65281f029192..0637ff4d73630bc2184533745ba7a9c9a631e15f 100644 --- a/paddle/fluid/train/CMakeLists.txt +++ b/paddle/fluid/train/CMakeLists.txt @@ -20,6 +20,8 @@ function(train_test TARGET_NAME) ARGS --dirname=${PYTHON_TESTS_DIR}/book/${TARGET_NAME}${arg}.train.model/) set_tests_properties(test_train_${TARGET_NAME}${arg} PROPERTIES DEPENDS test_${TARGET_NAME}) + set_tests_properties(test_train_${TARGET_NAME}${arg} + PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE") endforeach() endfunction(train_test) diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 6f1b01b2d2fdfc0b0570abd1b0694866afd1c645..c896c2595ff8075f258eb592286921f11a866a3b 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -561,6 +561,195 @@ function bind_test() { wait } +function parallel_test() { + mkdir -p ${PADDLE_ROOT}/build + cd ${PADDLE_ROOT}/build + if [ ${WITH_TESTING:-ON} == "ON" ] ; then + cat < ${CODE}" ; + EXIT_CODE=1; + fi + done + wait; # wait for all subshells to finish + + echo "EXIT_CODE => $EXIT_CODE" + if [[ "${EXIT_CODE}" != "0" ]]; then + exit "$EXIT_CODE" + fi + fi +} + +EXIT_CODE=0; +function caught_error() { + for job in `jobs -p`; do + # echo "PID => ${job}" + if ! wait ${job} ; then + echo "At least one test failed with exit code => $?" ; + EXIT_CODE=1; + fi + done +} + +function card_test() { + set -m + + # get the CUDA device count + CUDA_DEVICE_COUNT=$(nvidia-smi -L | wc -l) + + testcases=$1 + if (( $# > 1 )); then + cardnumber=$2 + if (( $cardnumber > $CUDA_DEVICE_COUNT )); then + cardnumber=$CUDA_DEVICE_COUNT + fi + else + cardnumber=$CUDA_DEVICE_COUNT + fi + + if [[ "$testcases" == "" ]]; then + return 0 + fi + + trap 'caught_error' CHLD + + NUM_PROC=$[CUDA_DEVICE_COUNT/$cardnumber] + for (( i = 0; i < $NUM_PROC; i++ )); do + # 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 + cuda_list=() + for (( j = 0; j < cardnumber; j++ )); do + if [ $j -eq 0 ]; then + cuda_list=("$[i*cardnumber]") + else + cuda_list="$cuda_list,$[i*cardnumber+j]" + fi + done + # echo $cuda_list + if [ ${TESTING_DEBUG_MODE:-OFF} == "ON" ] ; then + if [[ $cardnumber == $CUDA_DEVICE_COUNT ]]; then + ctest -I $i,,$NUM_PROC -R "($testcases)" -V & + else + env CUDA_VISIBLE_DEVICES=$cuda_list ctest -I $i,,$NUM_PROC -R "($testcases)" -V & + fi + else + if [[ $cardnumber == $CUDA_DEVICE_COUNT ]]; then + ctest -I $i,,$NUM_PROC -R "($testcases)" --output-on-failure & + else + # echo "env CUDA_VISIBLE_DEVICES=$cuda_list ctest -I $i,,$NUM_PROC -R \"($testcases)\" --output-on-failure &" + env CUDA_VISIBLE_DEVICES=$cuda_list ctest -I $i,,$NUM_PROC -R "($testcases)" --output-on-failure & + fi + fi + done + + wait; # wait for all subshells to finish +} + +function aggresive_test() { + mkdir -p ${PADDLE_ROOT}/build + cd ${PADDLE_ROOT}/build + if [ ${WITH_TESTING:-ON} == "ON" ] ; then + cat <