Skip to content

Commit

Permalink
Optimize Docker Build Layers and Add Sudo Privileges for Fast-LLM Con…
Browse files Browse the repository at this point in the history
…tainer (#2)
  • Loading branch information
tscholak authored Oct 21, 2024
1 parent 3ee5497 commit a21f9b5
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions Dockerfile
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/

0 comments on commit a21f9b5

Please sign in to comment.