Skip to content

Commit b03eace

Browse files
authored
Move TORCH_VERSION ARG below the FROM (#1161)
This is necessary to make it available with that build context. The other ARGs are above because they are used in the FROM statement themselves but not the build context of the last image. I also updated the URL for installing `torch_xla`. The version of Torch should not include the minor version.
1 parent b6ba531 commit b03eace

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tpu/Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
ARG BASE_IMAGE_TAG
22
ARG LIBTPU_IMAGE_TAG
33
ARG TENSORFLOW_VERSION
4-
ARG TORCH_VERSION
54

65
FROM gcr.io/cloud-tpu-v2-images/libtpu:${LIBTPU_IMAGE_TAG} as libtpu
76
FROM gcr.io/kaggle-images/python-tpu-tensorflow-whl:python-${BASE_IMAGE_TAG}-${TENSORFLOW_VERSION} AS tensorflow_whl
87
FROM gcr.io/kaggle-images/python:${BASE_IMAGE_TAG}
98

9+
# We need to define the ARG here to get the ARG below the FROM statement to access it within this build context
10+
# See: https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
11+
ARG TORCH_VERSION
12+
1013
ENV ISTPUVM=1
1114

1215
COPY --from=libtpu /libtpu.so /lib
@@ -19,7 +22,8 @@ RUN pip install /tmp/tensorflow_pkg/tensorflow*.whl && \
1922
# https://cloud.google.com/tpu/docs/pytorch-xla-ug-tpu-vm#changing_pytorch_version
2023
RUN pip uninstall -y torch && \
2124
pip install torch==${TORCH_VERSION} && \
22-
pip install torch_xla[tpuvm] -f https://storage.googleapis.com/tpu-pytorch/wheels/tpuvm/torch_xla-${TORCH_VERSION}-cp37-cp37m-linux_x86_64.whl && \
25+
# The URL doesn't include patch version. i.e. must use 1.11 instead of 1.11.0
26+
pip install torch_xla[tpuvm] -f https://storage.googleapis.com/tpu-pytorch/wheels/tpuvm/torch_xla-${TORCH_VERSION%.*}-cp37-cp37m-linux_x86_64.whl && \
2327
/tmp/clean-layer.sh
2428

2529
# https://cloud.google.com/tpu/docs/jax-quickstart-tpu-vm#install_jax_on_your_cloud_tpu_vm

0 commit comments

Comments
 (0)