Skip to content

Commit 0073e33

Browse files
pytorchbotclee2000
andauthored
[CI] Use sccache installed in docker image in xla build (pytorch#153983)
[CI] Use sccache installed in docker image in xla build (pytorch#153002) The edited comment should have the info. The code change looks large, but its copied from the install_cache script that our docker images use https://github.com/pytorch/pytorch/blob/6a8006472e431f872ca40c7aad250b61105de583/.ci/docker/common/install_cache.sh#L42 Sccache stopped working on xla at some point near dec 17 2023. I am not sure what commit caused it. I think it was having trouble writing to the cache. Either way, there is an sccache already installed on the docker image, so we should use that instead of a binary from s3 which we're probably no longer sure where it came from/what commit it was built from The one in the docker image is installed here https://github.com/pytorch/xla/blob/69d438ee65cc250c974ca80edd80462ffbb2e163/.github/upstream/Dockerfile#L61 and is also very old, so I have pytorch/xla#9102 to update it sccache still not writing properly, i will investigate, but xla build currently broken after the above xla pr, and this should fix it Pull Request resolved: pytorch#153002 Approved by: https://github.com/malfet (cherry picked from commit cbcb57d) Co-authored-by: Catherine Lee <[email protected]>
1 parent 92d3286 commit 0073e33

File tree

1 file changed

+35
-16
lines changed

1 file changed

+35
-16
lines changed

.ci/pytorch/install_cache_xla.sh

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,50 @@
11
#!/bin/bash
22

33
# Script for installing sccache on the xla build job, which uses xla's docker
4-
# image and doesn't have sccache installed on it. This is mostly copied from
5-
# .ci/docker/install_cache.sh. Changes are: removing checks that will always
6-
# return the same thing, ex checks for for rocm, CUDA, and changing the path
7-
# where sccache is installed, and not changing /etc/environment.
4+
# image, which has sccache installed but doesn't write the stubs. This is
5+
# mostly copied from .ci/docker/install_cache.sh. Changes are: removing checks
6+
# that will always return the same thing, ex checks for for rocm, CUDA, changing
7+
# the path where sccache is installed, not changing /etc/environment, and not
8+
# installing/downloading sccache as it is already in the docker image.
89

910
set -ex -o pipefail
1011

11-
install_binary() {
12-
echo "Downloading sccache binary from S3 repo"
13-
curl --retry 3 https://s3.amazonaws.com/ossci-linux/sccache -o /tmp/cache/bin/sccache
14-
}
15-
1612
mkdir -p /tmp/cache/bin
17-
mkdir -p /tmp/cache/lib
1813
export PATH="/tmp/cache/bin:$PATH"
1914

20-
install_binary
21-
chmod a+x /tmp/cache/bin/sccache
22-
2315
function write_sccache_stub() {
2416
# Unset LD_PRELOAD for ps because of asan + ps issues
2517
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90589
26-
# shellcheck disable=SC2086
27-
# shellcheck disable=SC2059
28-
printf "#!/bin/sh\nif [ \$(env -u LD_PRELOAD ps -p \$PPID -o comm=) != sccache ]; then\n exec sccache $(which $1) \"\$@\"\nelse\n exec $(which $1) \"\$@\"\nfi" > "/tmp/cache/bin/$1"
18+
if [ "$1" == "gcc" ]; then
19+
# Do not call sccache recursively when dumping preprocessor argument
20+
# For some reason it's very important for the first cached nvcc invocation
21+
cat >"/tmp/cache/bin/$1" <<EOF
22+
#!/bin/sh
23+
24+
# sccache does not support -E flag, so we need to call the original compiler directly in order to avoid calling this wrapper recursively
25+
for arg in "\$@"; do
26+
if [ "\$arg" = "-E" ]; then
27+
exec $(which "$1") "\$@"
28+
fi
29+
done
30+
31+
if [ \$(env -u LD_PRELOAD ps -p \$PPID -o comm=) != sccache ]; then
32+
exec sccache $(which "$1") "\$@"
33+
else
34+
exec $(which "$1") "\$@"
35+
fi
36+
EOF
37+
else
38+
cat >"/tmp/cache/bin/$1" <<EOF
39+
#!/bin/sh
40+
41+
if [ \$(env -u LD_PRELOAD ps -p \$PPID -o comm=) != sccache ]; then
42+
exec sccache $(which "$1") "\$@"
43+
else
44+
exec $(which "$1") "\$@"
45+
fi
46+
EOF
47+
fi
2948
chmod a+x "/tmp/cache/bin/$1"
3049
}
3150

0 commit comments

Comments
 (0)