Skip to content

Commit

Permalink
Set MAX_JOBS to nproc - 1 if using sccache to compile CUDA (#7361)
Browse files Browse the repository at this point in the history
* Set MAX_JOBS to nproc - 1 if using sccache to compile CUDA

* Change JOBS setting in tools/cpp_build/build_common.sh
  • Loading branch information
yf225 authored May 10, 2018
1 parent 78c3d8c commit 6a118b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .jenkins/pytorch/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tools/cpp_build/build_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"]]
Expand Down

0 comments on commit 6a118b2

Please sign in to comment.