Skip to content

Commit 2db7958

Browse files
gunanyifeif
authored andcommitted
Fix test_installation to skip using parallel_gpu_execute when not using GPU. (tensorflow#5186)
(cherry picked from commit 446b1cb)
1 parent 1a52bb1 commit 2db7958

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

tensorflow/tools/ci_build/builds/test_installation.sh

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@
4747
# TF_BUILD_BAZEL_CLEAN, if set to any non-empty and non-0 value, directs the
4848
# script to perform bazel clean prior to main build and test steps.
4949
#
50-
# TF_BUILD_SERIAL_INSTALL_TESTS, if set to any non-empty and non-0 value,
51-
# will force the Python install tests to run serially, overriding than the
52-
# concurrent testing behavior.
50+
# TF_BUILD_USE_GPU, if set to 1, limits the number of concurrent tests to
51+
# the number stored in TF_GPU_COUNT and assigns each test to a different GPU.
5352
#
5453
# TF_GPU_COUNT, Set the number of GPUs in the system. We run only this many
5554
# concurrent tests when running GPU tests.
@@ -411,21 +410,21 @@ SKIP_COUNTER=0
411410
FAILED_TESTS=""
412411
FAILED_TEST_LOGS=""
413412

414-
N_JOBS=$(grep -c ^processor /proc/cpuinfo)
415-
if [[ -z ${N_JOBS} ]]; then
416-
# Try the Mac way of getting number of CPUs
417-
N_JOBS=$(sysctl -n hw.ncpu)
418-
fi
419-
420-
if [[ -z ${N_JOBS} ]]; then
421-
N_JOBS=8
422-
echo "Cannot determine the number of processors"
423-
echo "Using default concurrent job counter ${N_JOBS}"
424-
fi
425-
426-
if [[ ! -z "${TF_BUILD_SERIAL_INSTALL_TESTS}" ]] &&
427-
[[ "${TF_BUILD_SERIAL_INSTALL_TESTS}" != "0" ]]; then
413+
if [[ "${TF_BUILD_USE_GPU}" == "1" ]]; then
428414
N_JOBS=$TF_GPU_COUNT
415+
else
416+
N_JOBS=$(grep -c ^processor /proc/cpuinfo)
417+
if [[ -z ${N_JOBS} ]]; then
418+
# Try the Mac way of getting number of CPUs
419+
N_JOBS=$(sysctl -n hw.ncpu)
420+
fi
421+
422+
# If still cannot determine the number of CPUs, pick 8.
423+
if [[ -z ${N_JOBS} ]]; then
424+
N_JOBS=8
425+
echo "Cannot determine the number of processors"
426+
echo "Using default concurrent job counter ${N_JOBS}"
427+
fi
429428
fi
430429

431430
echo "Running Python tests-on-install with ${N_JOBS} concurrent jobs..."
@@ -485,9 +484,14 @@ while true; do
485484
TEST_LOGS="${TEST_LOGS} ${TEST_LOG}"
486485

487486
# Launch test asynchronously
488-
"${SCRIPT_DIR}/../gpu_build/parallel_gpu_execute.sh" \
487+
if [[ "${TF_BUILD_USE_GPU}" == "1" ]]; then
488+
"${SCRIPT_DIR}/../gpu_build/parallel_gpu_execute.sh" \
489+
"${SCRIPT_DIR}/py_test_delegate.sh" \
490+
"${PYTHON_BIN_PATH}" "${PY_TEST_DIR}/${TEST_BASENAME}" "${TEST_LOG}" &
491+
else
489492
"${SCRIPT_DIR}/py_test_delegate.sh" \
490-
"${PYTHON_BIN_PATH}" "${PY_TEST_DIR}/${TEST_BASENAME}" "${TEST_LOG}" &
493+
"${PYTHON_BIN_PATH}" "${PY_TEST_DIR}/${TEST_BASENAME}" "${TEST_LOG}" &
494+
fi
491495

492496
if [[ "${TEST_COUNTER}" -ge "${N_PAR_TESTS}" ]]; then
493497
# Run in exclusive mode

tensorflow/tools/ci_build/ci_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ BUILD_TAG="${BUILD_TAG:-tf_ci}"
105105
# Add extra params for cuda devices and libraries for GPU container.
106106
if [ "${CONTAINER_TYPE}" == "gpu" ]; then
107107
# GPU pip tests-on-install concurrency is limited to the number of GPUs.
108-
GPU_EXTRA_PARAMS="${GPU_EXTRA_PARAMS} -e TF_BUILD_SERIAL_INSTALL_TESTS=1"
108+
GPU_EXTRA_PARAMS="${GPU_EXTRA_PARAMS} -e TF_BUILD_USE_GPU=1"
109109
else
110110
GPU_EXTRA_PARAMS=""
111111
fi

0 commit comments

Comments
 (0)