-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize Docker Build Layers and Add Sudo Privileges for Fast-LLM Con…
…tainer (#2)
- Loading branch information
Showing
1 changed file
with
17 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,37 @@ | ||
# syntax=docker/dockerfile:1.7-labs | ||
FROM nvcr.io/nvidia/pytorch:24.07-py3 | ||
|
||
# git-lfs is needed to interact with the huggingface hub | ||
# Install git-lfs for Huggingface hub interaction and sudo for system adjustments | ||
RUN apt-get update \ | ||
&& apt-get install git-lfs \ | ||
&& apt-get install --no-install-recommends -y git-lfs sudo util-linux \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& git lfs install | ||
|
||
# Add a user for Fast-LLM with sudo privileges for runtime adjustments | ||
ARG FAST_LLM_USER_ID=1000 | ||
RUN useradd -m -u $FAST_LLM_USER_ID -s /bin/bash fast_llm \ | ||
&& echo 'fast_llm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers | ||
|
||
RUN useradd -m -u $FAST_LLM_USER_ID -s /bin/bash -d /home/fast_llm fast_llm | ||
USER fast_llm | ||
WORKDIR /app | ||
ENV PYTHONPATH=/app:/app:/app/Megatron-LM | ||
ENV PATH=$PATH:/app:/home/fast_llm/.local/bin/ | ||
|
||
COPY --chown=fast_llm setup.py setup.cfg ./ | ||
COPY --chown=fast_llm fast_llm/__init__.py ./fast_llm/ | ||
# Environment settings for Python and PATH | ||
ENV PYTHONPATH=/app:/app/Megatron-LM \ | ||
PATH=$PATH:/home/fast_llm/.local/bin/ | ||
|
||
# Copy the dependency files and install dependencies | ||
COPY --chown=fast_llm setup.py setup.cfg pyproject.toml ./ | ||
RUN PIP_NO_INPUT=1 pip3 install --no-cache-dir -e ".[CORE,OPTIONAL,DEV]" | ||
|
||
COPY --chown=fast_llm fast_llm/csrc/ ./fast_llm/csrc/ | ||
# Compile the C++ extensions (fast_llm/csrc) | ||
COPY --chown=fast_llm ./fast_llm/csrc/ fast_llm/csrc/ | ||
RUN make -C ./fast_llm/csrc/ | ||
|
||
# Copy the rest of the code | ||
COPY --chown=fast_llm ./Megatron-LM Megatron-LM | ||
COPY --chown=fast_llm ./examples examples | ||
COPY --chown=fast_llm ./tests tests | ||
COPY --chown=fast_llm ./tools tools | ||
COPY --chown=fast_llm ./fast_llm fast_llm | ||
COPY --chown=fast_llm fast_llm/tools/train.py pyproject.toml ./ | ||
|
||
# Copy the main source code for Fast-LLM and install in editable mode | ||
COPY --exclude=./fast_llm/csrc/ --chown=fast_llm ./fast_llm/ fast_llm/ |