Skip to content

Commit

Permalink
clean up dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
areusch committed Aug 12, 2021
1 parent 4ae07da commit e80ec7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 4 additions & 1 deletion docker/bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,11 @@ if [ -n "${CI+x}" -a -z "${CPUSET_CPUS}" ]; then
fi
fi

echo "CPUSET_CPUS ${CPUSET_CPUS}"
if [ -n "${CPUSET_CPUS}" ]; then
if [ -z "$(echo ${CPUSET_CPUS} | sed -E '/^[0-9]+-[0-9]+$/ p; /.*/ d')" ]; then
echo "error: --cpuset-cpus: must specify in the form <m>-<n>; got ${CPUSET_CPUS}"
exit 2
fi
CPUSET_CPUS_LOWER_BOUND=$(echo "${CPUSET_CPUS}" | sed -E 's/^([0-9]+)-.*$/\1/g')
CPUSET_CPUS_UPPER_BOUND=$(echo "${CPUSET_CPUS}" | sed -E 's/^.*-([0-9]+)$/\1/g')
CPUSET_NUM_CPUS=$(expr "${CPUSET_CPUS_UPPER_BOUND}" - "${CPUSET_CPUS_LOWER_BOUND}" + 1) || /bin/true
Expand Down
19 changes: 12 additions & 7 deletions tests/scripts/setup-pytest-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,27 @@ export PYTHONPATH="${TVM_PATH}/python"
export TVM_PYTEST_RESULT_DIR="${TVM_PATH}/build/pytest-results"
mkdir -p "${TVM_PYTEST_RESULT_DIR}"

if [ -n "${CI_CPUSET_CPUS-}" ]; then
# When --cpuset-cpus has been passed to docker (this is set by docker/bash.sh),
# use all possible CPUs.
PYTEST_NUM_CPUS=$(nproc)
if [ -n "${CI_CPUSET_NUM_CPUS-}" ]; then
# When the # of CPUs has been restricted (e.g. when --cpuset-cpus has been passed to docker by
# docker/bash.sh), explicitly use all available CPUs. This environment variable is set by
# docker/bash.sh when it sets --cpuset-cpus.
PYTEST_NUM_CPUS="${CI_CPUSET_NUM_CPUS}"
else
# Else attempt to use $(nproc) - 1.
PYTEST_NUM_CPUS=$(nproc)
if [ -z "${PYTEST_NUM_CPUS}" ]; then
echo "WARNING: nproc failed; running pytest with only 1 CPU"
PYTEST_NUM_CPUS=1
elif [ ${PYTEST_NUM_CPUS} -gt 1 ]; then
PYTEST_NUM_CPUS=$(expr ${PYTEST_NUM_CPUS} - 1) # Don't nuke interactive work.
fi
fi

if [ ${PYTEST_NUM_CPUS} -gt 8 ]; then
PYTEST_NUM_CPUS=8 # It usually doesn't make sense to launch > 8 workers
# Don't use >4 CPUs--in general, we only use 4 CPUs in testing, so we want to retain this
# maximum for the purposes of reproducing the CI. You can still override this by setting
# --cpuset-cpus in docker/bash.sh.
if [ ${PYTEST_NUM_CPUS} -gt 4 ]; then
PYTEST_NUM_CPUS=4
fi
fi

function run_pytest() {
Expand Down

0 comments on commit e80ec7f

Please sign in to comment.