@@ -196,6 +196,10 @@ RUN ${PIP} --no-cache-dir install --upgrade \
196196 "setuptools>=81" \
197197 wheel
198198
199+ # Install UV for faster package installation
200+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh
201+ ENV PATH="/root/.cargo/bin:${PATH}"
202+
199203# Some TF tools expect a "python" binary
200204RUN ln -s $(which ${PYTHON}) /usr/local/bin/python \
201205 && ln -s $(which ${PIP}) /usr/bin/pip
@@ -269,7 +273,7 @@ FROM common AS ec2
269273
270274ARG TF_URL
271275
272- RUN ${PIP} install --no-cache-dir -U \
276+ RUN uv pip install --system -- no-cache-dir \
273277 ${TF_URL} \
274278 "tensorflow-io==0.37.*" \
275279 tensorflow-datasets
@@ -315,10 +319,6 @@ ARG TF_URL
315319# sagemaker-specific environment variable
316320ENV SAGEMAKER_TRAINING_MODULE sagemaker_tensorflow_container.training:main
317321
318- # Install UV for faster package installation
319- RUN curl -LsSf https://astral.sh/uv/install.sh | sh
320- ENV PATH="/root/.cargo/bin:${PATH}"
321-
322322# https://github.com/yaml/pyyaml/issues/601
323323# PyYaml less than 6.0.1 failes to build with cython v3 and above.
324324# tf-models-official uses older versions, breaking the install.
@@ -346,9 +346,8 @@ RUN uv pip install --system --no-cache-dir \
346346 && uv pip install --system --no-cache-dir \
347347 ${TF_URL} \
348348 "tensorflow-io==0.37.*" \
349- tensorflow-datasets
350-
351- # Rust/cargo already installed with UV
349+ tensorflow-datasets \
350+ && rm -rf /root/.cache/uv /root/.cargo/registry
352351
353352RUN uv pip install --system --no-cache-dir \
354353 numba \
@@ -357,7 +356,8 @@ RUN uv pip install --system --no-cache-dir \
357356 "opencv-python==4.11.0.86" \
358357 plotly \
359358 seaborn \
360- shap
359+ shap \
360+ && rm -rf /root/.cache/uv
361361
362362RUN uv pip install --system --no-cache-dir \
363363 sagemaker \
@@ -368,7 +368,8 @@ RUN uv pip install --system --no-cache-dir \
368368 sagemaker-studio-analytics-extension \
369369 sparkmagic==0.22.0 \
370370 sagemaker-studio-sparkmagic-lib \
371- smclarify
371+ smclarify \
372+ && rm -rf /root/.cache/uv
372373
373374# Re-pin numpy after all installs to ensure TF compatibility
374375RUN uv pip install --system --no-cache-dir "numpy==1.26.4"
0 commit comments