Use new sccache for RocM builds (#42134)

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/42134

Reviewed By: seemethere

Differential Revision: D22782146

Pulled By: malfet

fbshipit-source-id: 85ba69a705600e30ae0eddbf654298b3dc6f96ed
diff --git a/.jenkins/pytorch/build.sh b/.jenkins/pytorch/build.sh
index 7d83243..8730b61 100755
--- a/.jenkins/pytorch/build.sh
+++ b/.jenkins/pytorch/build.sh
@@ -7,6 +7,13 @@
 # shellcheck disable=SC2034
 COMPACT_JOB_NAME="${BUILD_ENVIRONMENT}"
 
+# Temp: use new sccache
+if [[ -n "$IN_CIRCLECI" && "$BUILD_ENVIRONMENT" == *rocm* ]]; then
+  # Download customized sccache
+  sudo curl --retry 3 http://repo.radeon.com/misc/.sccache_amd/sccache -o /opt/cache/bin/sccache
+  sudo chmod 755 /opt/cache/bin/sccache
+fi
+
 source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
 
 # For distributed, four environmental configs:
@@ -126,7 +133,7 @@
 
   # ROCm CI is using Caffe2 docker images, which needs these wrapper
   # scripts to correctly use sccache.
-  if [ -n "${SCCACHE_BUCKET}" ]; then
+  if [[ -n "${SCCACHE_BUCKET}" && -z "$IN_CIRCLECI" ]]; then
     mkdir -p ./sccache
 
     SCCACHE="$(which sccache)"
@@ -150,8 +157,8 @@
     export PATH="$CACHE_WRAPPER_DIR:$PATH"
   fi
 
-  # Set ROCM_ARCH to gtx900 and gtx906
-  if [[ -n "$CIRCLECI" ]]; then
+  if [[ -n "$IN_CIRCLECI" ]]; then
+      # Set ROCM_ARCH to gtx900 and gtx906 in CircleCI
       echo "Limiting PYTORCH_ROCM_ARCH to gfx90[06] for CircleCI builds"
       export PYTORCH_ROCM_ARCH="gfx900;gfx906"
   fi