Skip to content

Commit 3e6df26

Browse files
authored
Try to reduce torch img size (#127)
* try to reduce torch img size * fix for non-torch situation
1 parent 2152a18 commit 3e6df26

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docker_core/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ RUN set -eux \
8383
&& ( $(grep -q "paddle" <<< "${ARG_PROFILE_PYTHON}") && ( \
8484
URL_PYPI_PADDLE="https://www.paddlepaddle.org.cn/packages/stable/${IDX}/" \
8585
&& PADDLE=$( [ -x "$(command -v nvcc)" ] && echo "paddlepaddle-gpu" || echo "paddlepaddle") \
86-
# && PADDLE_VER=$(pip index versions ${PADDLE} -f ${URL_PYPI_PADDLE} | grep 'Available' | cut -d ":" -f 2 | tr ', ' '\n' | grep ${CUDA_VER:-'.'} | head -n 1) \
87-
# && V=$(echo ${PADDLE}==${PADDLE_VER}) && echo "to install paddle: ${V}" \
8886
&& pip install --no-cache-dir --root-user-action=ignore -U --pre --index-url ${URL_PYPI_PADDLE} "${PADDLE}" \
8987
) || echo "Skip paddle install" ) \
9088
# -----------------------------
@@ -93,6 +91,11 @@ RUN set -eux \
9391
[ -f "/opt/utils/install_list_PY_${profile}.apt" ] && install_apt "/opt/utils/install_list_PY_${profile}.apt" || echo "apt install skipped for ${profile}" ; \
9492
[ -f "/opt/utils/install_list_PY_${profile}.pip" ] && install_pip "/opt/utils/install_list_PY_${profile}.pip" || echo "pip install skipped for ${profile}" ; \
9593
) ; done \
94+
&& if [ "$(echo "${IDX}" | cut -c1-2)" = "cu" ] && echo "${ARG_PROFILE_PYTHON}" | grep -qE "torch|paddle" ; then \
95+
echo "Try to uninstall nvidia python packages to reduce storage size..." \
96+
&& pip freeze | grep -i '^nvidia-' | cut -d'=' -f1 | xargs -r pip uninstall -y \
97+
&& apt-get -qq update --fix-missing && apt-get -qq install -y --no-install-recommends --allow-change-held-packages libcusparselt0 libnccl2 libnccl-dev ; \
98+
fi \
9699
# -----------------------------
97100
&& if echo "${ARG_PROFILE_GO}" | grep -q "base" ; then \
98101
echo "Installing GO: ${ARG_PROFILE_GO}" && setup_GO ; \

0 commit comments

Comments
 (0)