Skip to content

Commit e99c295

Browse files
yeounohManfeiBai
authored andcommitted
Allow /dev/shm as sandboxed build base (#4460)
1 parent 089b4a6 commit e99c295

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

build_torch_xla_libs.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ if [[ "$XLA_BAZEL_VERBOSE" == "1" ]]; then
3535
fi
3636

3737
BUILD_STRATEGY="standalone"
38+
SANDBOX_BASE="${XLA_SANDBOX_BASE}"
39+
if [ -z "$XLA_SANDBOX_BASE" ]; then
40+
SANDBOX_BASE="/tmp"
41+
fi
3842
if [[ "$XLA_SANDBOX_BUILD" == "1" ]]; then
39-
BUILD_STRATEGY="sandboxed --sandbox_base=/dev/shm"
43+
BUILD_STRATEGY="sandboxed --sandbox_base=${SANDBOX_BASE}"
4044
else
4145
# We can remove this after https://github.com/bazelbuild/bazel/issues/15359 is resolved
4246
unset CC
@@ -84,7 +88,7 @@ else
8488
cp -r -u -p $THIRD_PARTY_DIR/xla_client $THIRD_PARTY_DIR/tensorflow/tensorflow/compiler/xla/
8589

8690
pushd $THIRD_PARTY_DIR/tensorflow
87-
# TensorFlow and its dependencies may introduce warning flags from newer compilers
91+
# TensorFlow and its dependencies may introduce warning flags from newer compilers
8892
# that PyTorch and PyTorch/XLA's default compilers don't recognize. They become error
8993
# while '-Werror' is used. Therefore, surpress the warnings.
9094
TF_EXTRA_FLAGS="--copt=-Wno-unknown-warning-option"

docker/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ ENV BUNDLE_LIBTPU "${tpuvm}"
3939
# Maximum number of jobs to use for bazel build
4040
ENV BAZEL_JOBS "${bazel_jobs}"
4141

42-
# This makes the bazel build behave more consistently, but it may slower.
42+
# This makes the bazel build behave more consistently, but runs slower.
4343
ENV XLA_SANDBOX_BUILD "1"
44+
ENV XLA_SANDBOX_BASE "/dev/shm"
4445

4546
# To get around issue of Cloud Build with recursive submodule update
4647
# clone recursively from pytorch/xla if building docker image with

docker/cloudbuild.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ steps:
55
- name: 'gcr.io/cloud-builders/docker'
66
args: [
77
'build',
8+
'--shm-size', '16gb',
89
'--build-arg', 'base_image=${_DOCKER_BASE_IMAGE}',
910
'--build-arg', 'cuda=${_CUDA}',
1011
'--build-arg', 'python_version=${_PYTHON_VERSION}',

docker/experimental/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ COPY build_torch_xla_libs.sh .
7777

7878
# TODO: Remove this when it's not required anymore
7979
ENV XLA_SANDBOX_BUILD=1
80+
ENV XLA_SANDBOX_BASE "/dev/shm"
8081

8182
ARG tpuvm
8283
ARG tf_cuda_compute_capabilities

0 commit comments

Comments
 (0)