Skip to content

Commit e5d2c96

Browse files
veritas9872joonhyung.lee
and
joonhyung.lee
authored
Test/deepspeed (#190)
* Change path color to cyan. Remove brew installation, which is not worth the effort. It now causes build failure because it cannot be installed as root. * Change color to cyan, which is more visible on a dark terminal than blue. * Removing brew installation, which was causing troo much trouble. * Moving the conda installation into the Ubuntu image to prevent issues from arising if conda is installed on a different Linux distribution. Also removing the brew installation, which was causing too much trouble. --------- Co-authored-by: joonhyung.lee <[email protected]>
1 parent 6c11e5a commit e5d2c96

File tree

3 files changed

+27
-65
lines changed

3 files changed

+27
-65
lines changed

dockerfiles/ngc.Dockerfile

+6-21
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,6 @@ RUN --mount=type=cache,target=${PIP_CACHE_DIR},sharing=locked \
7272
$conda env update -p /opt/conda --file /tmp/env/environment.yaml && \
7373
printf "channels:\n - conda-forge\n - nodefaults\nssl_verify: false\n" > /opt/conda/.condarc
7474

75-
########################################################################
76-
FROM ${BASE_IMAGE} AS install-brew
77-
78-
LABEL maintainer="[email protected]"
79-
ENV LANG=C.UTF-8
80-
ENV LC_ALL=C.UTF-8
81-
ENV PYTHONIOENCODING=UTF-8
82-
ARG PYTHONDONTWRITEBYTECODE=1
83-
ARG PYTHONUNBUFFERED=1
84-
85-
# Install HomeBrew.
86-
ARG BREW_URL=https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
87-
RUN NONINTERACTIVE=1 /bin/bash -c "$(curl -fksSL ${BREW_URL})"
88-
8975
########################################################################
9076
FROM ${BASE_IMAGE} AS train-base
9177

@@ -131,7 +117,6 @@ RUN groupadd -f -g ${GID} ${GRP} && \
131117

132118
# Get conda with the directory ownership given to the user.
133119
COPY --link --from=install-conda --chown=${UID}:${GID} /opt/conda /opt/conda
134-
COPY --link --from=install-brew --chown=${UID}:${GID} /home/linuxbrew /home/linuxbrew
135120

136121
########################################################################
137122
FROM train-base AS train-adduser-exclude
@@ -142,7 +127,6 @@ FROM train-base AS train-adduser-exclude
142127
# to a container repository for reproducibility.
143128
# Note that `zsh` configs are available but these images do not require `zsh`.
144129
COPY --link --from=install-conda /opt/conda /opt/conda
145-
COPY --link --from=install-brew /home/linuxbrew /home/linuxbrew
146130

147131
########################################################################
148132
FROM train-adduser-${ADD_USER} AS train
@@ -179,6 +163,10 @@ RUN ln -s /opt/conda/lib/$(python -V | awk -F '[ \.]' '{print "python" $2 "." $3
179163
# Setting the prompt to `pure`.
180164
{ echo "fpath+=${PURE_PATH}"; \
181165
echo "autoload -Uz promptinit; promptinit"; \
166+
# Change the `tmux` path color to cyan since
167+
# the default blue is unreadable on a dark terminal.
168+
echo "zmodload zsh/nearcolor"; \
169+
echo "zstyle :prompt:pure:path color cyan"; \
182170
echo "prompt pure"; \
183171
} >> ${ZDOTDIR}/.zshrc && \
184172
# Add autosuggestions from terminal history. May be somewhat distracting.
@@ -192,11 +180,8 @@ RUN ln -s /opt/conda/lib/$(python -V | awk -F '[ \.]' '{print "python" $2 "." $3
192180
echo "source ${ZSHS_PATH}/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR}/.zshrc && \
193181
# Configure `tmux` to use `zsh` as a non-login shell on startup.
194182
echo "set -g default-command $(which zsh)" >> /etc/tmux.conf && \
195-
# Activate HomeBrew for Linux on login.
196-
{ echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'; \
197-
# For some reason, `tmux` does not read `/etc/tmux.conf`.
198-
echo 'cp /etc/tmux.conf ${HOME}/.tmux.conf'; \
199-
} >> ${ZDOTDIR}/.zprofile && \
183+
# For some reason, `tmux` does not read `/etc/tmux.conf`.
184+
echo 'cp /etc/tmux.conf ${HOME}/.tmux.conf' >> ${ZDOTDIR}/.zprofile && \
200185
# Change `ZDOTDIR` directory permissions to allow configuration sharing.
201186
chmod 755 ${ZDOTDIR} && \
202187
# Clear out `/tmp` and restore its default permissions.

dockerfiles/simple.Dockerfile

+15-25
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,11 @@ RUN git clone --depth 1 ${PURE_URL} /opt/zsh/pure
3636
RUN git clone --depth 1 ${ZSHA_URL} /opt/zsh/zsh-autosuggestions
3737
RUN git clone --depth 1 ${ZSHS_URL} /opt/zsh/zsh-syntax-highlighting
3838

39-
COPY --link ../reqs/simple-apt.requirements.txt /tmp/apt/requirements.txt
40-
41-
# Both `conda` and `brew` are installed here despite worries that
42-
# the differences between the base images will cause issues.
4339
ARG CONDA_URL
4440
WORKDIR /tmp/conda
45-
RUN curl -fksSL -o /tmp/conda/miniconda.sh ${CONDA_URL} && \
46-
/bin/bash /tmp/conda/miniconda.sh -b -p /opt/conda && \
47-
printf "channels:\n - conda-forge\n - nodefaults\nssl_verify: false\n" > /opt/conda/.condarc && \
48-
find /opt/conda -type d -name '__pycache__' | xargs rm -rf
41+
RUN curl -fksSL -o /tmp/conda/miniconda.sh ${CONDA_URL}
4942

50-
ARG CONDA_MANAGER
51-
ARG PATH=/opt/conda/bin:${PATH}
52-
ARG conda=/opt/conda/bin/${CONDA_MANAGER}
53-
ARG HOMEBREW_CACHE=/home/linuxbrew/.cache
54-
ARG BREW_URL=https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
55-
RUN --mount=type=cache,target=${HOMEBREW_CACHE},sharing=locked \
56-
$conda install -y curl git && $conda clean -fya && \
57-
NONINTERACTIVE=1 /bin/bash -c "$(curl -fksSL ${BREW_URL})"
43+
COPY --link ../reqs/simple-apt.requirements.txt /tmp/apt/requirements.txt
5844

5945
WORKDIR /
6046

@@ -78,7 +64,11 @@ ARG conda=/opt/conda/bin/${CONDA_MANAGER}
7864
# Use `docker builder prune` to clear out the build cache if it does.
7965
ARG PIP_CACHE_DIR=/root/.cache/pip
8066
ARG CONDA_PKGS_DIRS=/opt/conda/pkgs
81-
COPY --link --from=stash /opt/conda /opt/conda
67+
RUN --mount=type=bind,from=stash,source=/tmp/conda,target=/tmp/conda \
68+
/bin/bash /tmp/conda/miniconda.sh -b -p /opt/conda && \
69+
printf "channels:\n - conda-forge\n - nodefaults\nssl_verify: false\n" > /opt/conda/.condarc && \
70+
find /opt/conda -type d -name '__pycache__' | xargs rm -rf
71+
8272
COPY --link ../reqs/simple-environment.yaml /tmp/req/environment.yaml
8373

8474
ARG INDEX_URL
@@ -107,7 +97,8 @@ ARG CONDA_MANAGER
10797
ARG conda=/opt/_conda/bin/${CONDA_MANAGER}
10898
RUN /bin/bash /tmp/conda/miniconda.sh -b -p /opt/_conda && \
10999
printf "channels:\n - conda-forge\n - nodefaults\nssl_verify: false\n" > /opt/_conda/.condarc && \
110-
$conda install conda-lock
100+
$conda install conda-lock && \
101+
find /opt/conda -type d -name '__pycache__' | xargs rm -rf
111102

112103
########################################################################
113104
FROM ${BASE_IMAGE} AS conda-lock-include
@@ -186,7 +177,6 @@ FROM train-base AS train-adduser-exclude
186177
# container registries such as Docker Hub. No users or interactive settings.
187178
# Note that `zsh` configs are available but these images do not require `zsh`.
188179
COPY --link --from=install-conda /opt/conda /opt/conda
189-
COPY --link --from=stash /home/linuxbrew /home/linuxbrew
190180

191181
########################################################################
192182
FROM train-base AS train-adduser-include
@@ -206,7 +196,6 @@ RUN groupadd -f -g ${GID} ${GRP} && \
206196

207197
# Get conda with the directory ownership given to the user.
208198
COPY --link --from=install-conda --chown=${UID}:${GID} /opt/conda /opt/conda
209-
COPY --link --from=stash --chown=${UID}:${GID} /home/linuxbrew /home/linuxbrew
210199

211200
########################################################################
212201
FROM train-adduser-${ADD_USER} AS train
@@ -239,6 +228,10 @@ COPY --link --from=stash /opt/zsh/pure ${PURE_PATH}
239228
COPY --link --from=stash /opt/zsh/zsh-syntax-highlighting ${ZSHS_PATH}
240229
RUN { echo "fpath+=${PURE_PATH}"; \
241230
echo "autoload -Uz promptinit; promptinit"; \
231+
# Change the `tmux` path color to cyan since
232+
# the default blue is unreadable on a dark terminal.
233+
echo "zmodload zsh/nearcolor"; \
234+
echo "zstyle :prompt:pure:path color cyan"; \
242235
echo "prompt pure"; \
243236
} >> ${ZDOTDIR}/.zshrc && \
244237
# Add autosuggestions from terminal history. May be somewhat distracting.
@@ -252,11 +245,8 @@ RUN { echo "fpath+=${PURE_PATH}"; \
252245
echo "source ${ZSHS_PATH}/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR}/.zshrc && \
253246
# Configure `tmux` to use `zsh` as a non-login shell on startup.
254247
echo "set -g default-command $(which zsh)" >> /etc/tmux.conf && \
255-
# Activate HomeBrew for Linux on login.
256-
{ echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'; \
257-
# For some reason, `tmux` does not read `/etc/tmux.conf`.
258-
echo 'cp /etc/tmux.conf ${HOME}/.tmux.conf'; \
259-
} >> ${ZDOTDIR}/.zprofile && \
248+
# For some reason, `tmux` does not read `/etc/tmux.conf`.
249+
echo 'cp /etc/tmux.conf ${HOME}/.tmux.conf' >> ${ZDOTDIR}/.zprofile && \
260250
# Change `ZDOTDIR` directory permissions to allow configuration sharing.
261251
chmod 755 ${ZDOTDIR} && \
262252
# Clear out `/tmp` and restore its default permissions.

dockerfiles/train.Dockerfile

+6-19
Original file line numberDiff line numberDiff line change
@@ -267,16 +267,6 @@ RUN if [ ! "$(lscpu | grep -q avx2)" ]; then CC="cc -mavx2"; fi && \
267267
python -m pip wheel --no-deps --wheel-dir /tmp/dist \
268268
Pillow-SIMD${PILLOW_SIMD_VERSION}
269269

270-
########################################################################
271-
FROM install-conda AS fetch-brew
272-
273-
ARG HOMEBREW_CACHE=/home/linuxbrew/.cache
274-
ARG BREW_URL=https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
275-
ARG PATH=/opt/conda/bin:${PATH}
276-
RUN --mount=type=cache,target=${HOMEBREW_CACHE},sharing=locked \
277-
$conda install -y curl git && $conda clean -fya && \
278-
NONINTERACTIVE=1 /bin/bash -c "$(curl -fksSL ${BREW_URL})"
279-
280270
########################################################################
281271
FROM ${GIT_IMAGE} AS clone-vision
282272

@@ -376,7 +366,6 @@ COPY --link --from=install-conda /opt/conda /opt/conda
376366
COPY --link --from=build-pillow /tmp/dist /tmp/dist
377367
COPY --link --from=build-vision /tmp/dist /tmp/dist
378368
COPY --link --from=fetch-pure /opt/zsh /opt/zsh
379-
COPY --link --from=fetch-brew /home/linuxbrew /home/linuxbrew
380369

381370
########################################################################
382371
FROM ${BUILD_IMAGE} AS train-builds-exclude
@@ -390,7 +379,6 @@ COPY --link --from=build-pillow /tmp/dist /tmp/dist
390379
COPY --link --from=fetch-torch /tmp/dist /tmp/dist
391380
COPY --link --from=fetch-vision /tmp/dist /tmp/dist
392381
COPY --link --from=fetch-pure /opt/zsh /opt/zsh
393-
COPY --link --from=fetch-brew /home/linuxbrew /home/linuxbrew
394382

395383
########################################################################
396384
FROM train-builds-${BUILD_MODE} AS train-builds
@@ -486,7 +474,6 @@ RUN groupadd -f -g ${GID} ${GRP} && \
486474

487475
# Get conda with the directory ownership given to the user.
488476
COPY --link --from=train-builds --chown=${UID}:${GID} /opt/conda /opt/conda
489-
COPY --link --from=train-builds --chown=${UID}:${GID} /home/linuxbrew /home/linuxbrew
490477

491478
########################################################################
492479
FROM train-base AS train-adduser-exclude
@@ -501,7 +488,6 @@ FROM train-base AS train-adduser-exclude
501488
# Note that this image does not require `zsh` but has `zsh` configs available.
502489

503490
COPY --link --from=train-builds /opt/conda /opt/conda
504-
COPY --link --from=train-builds /home/linuxbrew /home/linuxbrew
505491

506492
########################################################################
507493
FROM train-adduser-${ADD_USER} AS train
@@ -539,6 +525,10 @@ ENV MALLOC_CONF="background_thread:true,metadata_thp:auto,dirty_decay_ms:30000,m
539525

540526
RUN { echo "fpath+=${PURE_PATH}"; \
541527
echo "autoload -Uz promptinit; promptinit"; \
528+
# Change the `tmux` path color to cyan since
529+
# the default blue is unreadable on a dark terminal.
530+
echo "zmodload zsh/nearcolor"; \
531+
echo "zstyle :prompt:pure:path color cyan"; \
542532
echo "prompt pure"; \
543533
} >> ${ZDOTDIR}/.zshrc && \
544534
# Add autosuggestions from terminal history. May be somewhat distracting.
@@ -552,11 +542,8 @@ RUN { echo "fpath+=${PURE_PATH}"; \
552542
echo "source ${ZSHS_PATH}/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR}/.zshrc && \
553543
# Configure `tmux` to use `zsh` as a non-login shell on startup.
554544
echo "set -g default-command $(which zsh)" >> /etc/tmux.conf && \
555-
# Activate HomeBrew for Linux on login.
556-
{ echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'; \
557-
# For some reason, `tmux` does not read `/etc/tmux.conf`.
558-
echo 'cp /etc/tmux.conf ${HOME}/.tmux.conf'; \
559-
} >> ${ZDOTDIR}/.zprofile && \
545+
# For some reason, `tmux` does not read `/etc/tmux.conf`.
546+
echo 'cp /etc/tmux.conf ${HOME}/.tmux.conf' >> ${ZDOTDIR}/.zprofile && \
560547
# Change `ZDOTDIR` directory permissions to allow configuration sharing.
561548
chmod 755 ${ZDOTDIR} && \
562549
# Clear out `/tmp` and restore its default permissions.

0 commit comments

Comments
 (0)