Skip to content

Commit a2ba4ea

Browse files
committed
Build tpu image with uv
This should significantly improve build times for this image. http://b/350047073
1 parent 79353b5 commit a2ba4ea

File tree

2 files changed

+55
-10
lines changed

2 files changed

+55
-10
lines changed

tpu/Dockerfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
5656

5757
# Packages needed by the Notebook editor
5858

59-
# Additional useful packages should be added here
60-
61-
RUN pip install tensorflow_hub https://storage.googleapis.com/cloud-tpu-tpuvm-artifacts/tensorflow/tf-${TENSORFLOW_VERSION}/tensorflow-${TENSORFLOW_VERSION}-${PYTHON_WHEEL_VERSION}-${PYTHON_WHEEL_VERSION}-${TF_LINUX_WHEEL_VERSION}.whl tensorflow-probability tensorflow-io \
62-
torch~=${TORCH_VERSION} https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch_xla-${TORCH_VERSION}+libtpu-${PYTHON_WHEEL_VERSION}-${PYTHON_WHEEL_VERSION}-${TORCH_LINUX_WHEEL_VERSION}.whl torchvision==${TORCHVISION_VERSION} torchaudio==${TORCHAUDIO_VERSION} \
63-
jax[tpu]==${JAX_VERSION} -f https://storage.googleapis.com/jax-releases/libtpu_releases.html trax flax optax git+https://github.com/deepmind/dm-haiku jraph distrax \
64-
papermill jupyterlab python-lsp-server[all] "jupyter-lsp==1.5.1" \
65-
pandas matplotlib opencv-python-headless librosa accelerate diffusers scikit-learn transformers \
66-
seaborn timm albumentations einops pyarrow fastparquet opencv-python \
67-
"keras>3" keras-cv keras-nlp \
68-
kagglehub && \
59+
# Additional useful packages should be added in the requirements.txt
60+
61+
# Bring in the requirements.txt and replace variables in it:
62+
RUN apt-get install -y gettext
63+
ADD tpu/requirements.txt /kaggle_requirements.txt
64+
RUN envsubst < /kaggle_requirements.txt > /requirements.txt
65+
66+
# Install uv and then install the requirements:
67+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
68+
RUN export PATH="${HOME}/.local/bin:${PATH}" && uv pip install --system -r /requirements.txt --prerelease=allow --find-links https://storage.googleapis.com/jax-releases/libtpu_releases.html && \
6969
/tmp/clean-layer.sh
7070

7171
# Tensorflow libtpu:

tpu/requirements.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Tensorflow packages
2+
https://storage.googleapis.com/cloud-tpu-tpuvm-artifacts/tensorflow/tf-${TENSORFLOW_VERSION}/tensorflow-${TENSORFLOW_VERSION}-${PYTHON_WHEEL_VERSION}-${PYTHON_WHEEL_VERSION}-${TF_LINUX_WHEEL_VERSION}.whl
3+
tensorflow_hub
4+
tensorflow-io
5+
tensorflow-probability
6+
# Torch packages
7+
torch~=${TORCH_VERSION}
8+
https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch_xla-${TORCH_VERSION}+libtpu-${PYTHON_WHEEL_VERSION}-${PYTHON_WHEEL_VERSION}-${TORCH_LINUX_WHEEL_VERSION}.whl
9+
torchaudio==${TORCHAUDIO_VERSION}
10+
torchvision==${TORCHVISION_VERSION}
11+
# Jax packages
12+
jax[tpu]==${JAX_VERSION}
13+
distrax
14+
flax
15+
git+https://github.com/deepmind/dm-haiku
16+
jraph
17+
optax
18+
trax
19+
# Jupyter packages
20+
jupyter-lsp==1.5.1
21+
jupyterlab
22+
papermill
23+
python-lsp-server[all]
24+
# Keras Packages
25+
keras>3
26+
keras-cv
27+
keras-nlp
28+
# Kaggle Packages
29+
kagglehub
30+
# Other useful packages, add more here
31+
accelerate
32+
albumentations
33+
diffusers
34+
einops
35+
fastparquet
36+
librosa
37+
matplotlib
38+
opencv-python
39+
opencv-python-headless
40+
pandas
41+
pyarrow
42+
scikit-learn
43+
seaborn
44+
timm
45+
transformers

0 commit comments

Comments
 (0)