From f824139505b1c6a8990186fad445c78576d1ceb0 Mon Sep 17 00:00:00 2001 From: Torsten Scholak Date: Thu, 10 Oct 2024 14:25:36 -0400 Subject: [PATCH 1/6] refactor Dockerfile to separate dependency install and source code, preserve compiled C++ artifacts, and add sudo for runtime adjustments --- Dockerfile | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2302c8bbf..5fa359cd9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,38 @@ 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 \ && 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:/app/Megatron-LM \ + PATH=$PATH:/home/fast_llm/.local/bin/ -RUN PIP_NO_INPUT=1 pip3 install --no-cache-dir -e ".[CORE,OPTIONAL,DEV]" - -COPY --chown=fast_llm fast_llm/csrc/ ./fast_llm/csrc/ -RUN make -C ./fast_llm/csrc/ +# 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 ".[CORE,OPTIONAL,DEV]" +# 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 ./ + +# 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 main source code for Fast-LLM and install in editable mode +COPY --chown=fast_llm ./fast_llm/ ./fast_llm/ \ + --exclude ./fast_llm/csrc/ +RUN PIP_NO_INPUT=1 pip3 install --no-deps -e . From 50de91281bdc9735a8ad3ccfc57f049584c20315 Mon Sep 17 00:00:00 2001 From: Torsten Scholak Date: Thu, 10 Oct 2024 14:30:32 -0400 Subject: [PATCH 2/6] refactor Dockerfile to separate dependency install and source code, preserve compiled C++ artifacts, and add sudo for runtime adjustments --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5fa359cd9..9a256b7cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7-labs FROM nvcr.io/nvidia/pytorch:24.07-py3 # Install git-lfs for Huggingface hub interaction and sudo for system adjustments @@ -29,10 +30,9 @@ COPY --chown=fast_llm ./tests tests COPY --chown=fast_llm ./tools tools # Compile the C++ extensions (fast_llm/csrc) -COPY --chown=fast_llm fast_llm/csrc/ ./fast_llm/csrc/ +COPY --chown=fast_llm ./fast_llm/csrc/ fast_llm/csrc/ RUN make -C ./fast_llm/csrc/ # Copy the main source code for Fast-LLM and install in editable mode -COPY --chown=fast_llm ./fast_llm/ ./fast_llm/ \ - --exclude ./fast_llm/csrc/ +COPY --exclude=./fast_llm/csrc/ --chown=fast_llm ./fast_llm/ fast_llm/ RUN PIP_NO_INPUT=1 pip3 install --no-deps -e . From 9ae57e0f1e26655490b86329c1cbea73f3ac3ab7 Mon Sep 17 00:00:00 2001 From: Torsten Scholak Date: Thu, 10 Oct 2024 15:17:47 -0400 Subject: [PATCH 3/6] add util-linux --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9a256b7cf..4a0ceedff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM nvcr.io/nvidia/pytorch:24.07-py3 # Install git-lfs for Huggingface hub interaction and sudo for system adjustments RUN apt-get update \ - && apt-get install --no-install-recommends -y git-lfs sudo \ + && apt-get install --no-install-recommends -y git-lfs sudo util-linux \ && rm -rf /var/lib/apt/lists/* \ && git lfs install From ade4b8e58977ea168b116e303b9fe76b2c21a7b7 Mon Sep 17 00:00:00 2001 From: Torsten Scholak Date: Wed, 16 Oct 2024 10:51:42 -0400 Subject: [PATCH 4/6] address review comments --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4a0ceedff..622ab6b1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,13 @@ USER fast_llm WORKDIR /app # Environment settings for Python and PATH -ENV PYTHONPATH=/app:/app:/app/Megatron-LM \ +ENV PYTHONPATH=/app:/app/Megatron-LM \ PATH=$PATH:/home/fast_llm/.local/bin/ +# 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 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 ".[CORE,OPTIONAL,DEV]" @@ -29,10 +33,6 @@ COPY --chown=fast_llm ./examples examples COPY --chown=fast_llm ./tests tests COPY --chown=fast_llm ./tools tools -# 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 main source code for Fast-LLM and install in editable mode COPY --exclude=./fast_llm/csrc/ --chown=fast_llm ./fast_llm/ fast_llm/ RUN PIP_NO_INPUT=1 pip3 install --no-deps -e . From 3c42057c8497ded2767762af2d6815aee1f610b6 Mon Sep 17 00:00:00 2001 From: Torsten Scholak Date: Wed, 16 Oct 2024 11:00:57 -0400 Subject: [PATCH 5/6] address review comments --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 622ab6b1c..4e994e9bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ RUN make -C ./fast_llm/csrc/ # 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 ".[CORE,OPTIONAL,DEV]" +RUN PIP_NO_INPUT=1 pip3 install --no-cache-dir -e ".[CORE,OPTIONAL,DEV]" # Copy the rest of the code COPY --chown=fast_llm ./Megatron-LM Megatron-LM @@ -35,4 +35,3 @@ COPY --chown=fast_llm ./tools tools # 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/ -RUN PIP_NO_INPUT=1 pip3 install --no-deps -e . From 8219f7eea78e22b66e583ad6266ea14c372875f9 Mon Sep 17 00:00:00 2001 From: Torsten Scholak Date: Fri, 18 Oct 2024 14:58:16 -0400 Subject: [PATCH 6/6] address review comments --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4e994e9bb..b12f966b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,14 +19,14 @@ WORKDIR /app ENV PYTHONPATH=/app:/app/Megatron-LM \ PATH=$PATH:/home/fast_llm/.local/bin/ -# 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 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]" +# 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