diff --git a/.jenkins/pytorch/build.sh b/.jenkins/pytorch/build.sh index fd60d9bfca..2f98ed5f9a 100755 --- a/.jenkins/pytorch/build.sh +++ b/.jenkins/pytorch/build.sh @@ -27,6 +27,11 @@ if ! which conda; then pip install mkl mkl-devel fi +# sccache will fail for CUDA builds if all cores are used for compiling +if [[ "$BUILD_ENVIRONMENT" == *cuda* ]] && which sccache > /dev/null; then + export MAX_JOBS=`expr $(nproc) - 1` +fi + WERROR=1 python setup.py install # Add the ATen test binaries so that they won't be git clean'ed away diff --git a/tools/cpp_build/build_common.sh b/tools/cpp_build/build_common.sh index 9b94277c0b..e16e87bf57 100755 --- a/tools/cpp_build/build_common.sh +++ b/tools/cpp_build/build_common.sh @@ -27,7 +27,9 @@ BUILD_TYPE=${BUILD_TYPE:-Debug} # Try to build with as many threads as we have cores, default to 4 if the # command fails. set +e -if [[ "$(uname)" == "Linux" ]]; then +if [ -n "$MAX_JOBS" ]; then # Use MAX_JOBS if it is set + JOBS=$MAX_JOBS +elif [[ "$(uname)" == "Linux" ]]; then # https://stackoverflow.com/questions/6481005/how-to-obtain-the-number-of-cpus-cores-in-linux-from-the-command-line JOBS="$(grep -c '^processor' /proc/cpuinfo)" else # if [[ "$(uname)" == "Darwin"]]