|
1 | 1 | # syntax=docker/dockerfile:1.7-labs
|
2 | 2 | FROM nvcr.io/nvidia/pytorch:24.07-py3
|
3 | 3 |
|
4 |
| -# Install git-lfs for Huggingface hub interaction and sudo for system adjustments |
| 4 | +# Install dependencies. |
5 | 5 | RUN apt-get update \
|
6 |
| - && apt-get install --no-install-recommends -y git-lfs sudo util-linux \ |
| 6 | + && apt-get install --no-install-recommends -y acl git-lfs \ |
7 | 7 | && rm -rf /var/lib/apt/lists/* \
|
8 | 8 | && git lfs install
|
9 | 9 |
|
10 |
| -# Add a user for Fast-LLM with sudo privileges for runtime adjustments |
11 |
| -ARG FAST_LLM_USER_ID=1000 |
12 |
| -RUN useradd -m -u $FAST_LLM_USER_ID -s /bin/bash fast_llm \ |
13 |
| - && echo 'fast_llm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers |
14 |
| - |
15 |
| -USER fast_llm |
| 10 | +# Set the working directory. |
16 | 11 | WORKDIR /app
|
| 12 | +# Set the permission to 777 for all files and directories in `/app`, `/home` and python install directories: |
| 13 | +# 1. Create directories explicitly because docker use the wrong permission for explicit creation. |
| 14 | +# 2. For the rest, set the default ACL to 777 for all users. |
| 15 | +RUN mkdir -m 777 /app/Megatron-LM /app/examples /app/fast_llm /app/tests /app/tools \ |
| 16 | + && setfacl -m d:u::rwx,d:g::rwx,d:o::rwx,u::rwx,g::rwx,o::rwx \ |
| 17 | + /app \ |
| 18 | + /home \ |
| 19 | + /usr \ |
| 20 | + /usr/local \ |
| 21 | + /usr/local/bin \ |
| 22 | + /usr/local/lib \ |
| 23 | + /usr/local/lib/python3.10 \ |
| 24 | + /usr/local/lib/python3.10/dist-packages \ |
| 25 | + /usr/local/lib/python3.10/dist-packages/__pycache__ |
17 | 26 |
|
18 |
| -# Environment settings for Python and PATH |
19 |
| -ENV PYTHONPATH=/app:/app/Megatron-LM \ |
20 |
| - PATH=$PATH:/home/fast_llm/.local/bin/ |
21 |
| - |
22 |
| -# Copy the dependency files and install dependencies |
23 |
| -COPY --chown=fast_llm setup.py setup.cfg pyproject.toml ./ |
24 |
| -COPY --chown=fast_llm ./fast_llm/csrc/ fast_llm/csrc/ |
25 |
| -RUN PIP_NO_INPUT=1 pip3 install --no-cache-dir --no-build-isolation -e ".[CORE,OPTIONAL,DEV]" |
| 27 | +# Copy dependency files with universal write permissions for all users. |
| 28 | +COPY --chmod=777 setup.py setup.cfg pyproject.toml ./ |
| 29 | +COPY --chmod=777 ./fast_llm/csrc/ fast_llm/csrc/ |
26 | 30 |
|
27 |
| -# Copy the rest of the code |
28 |
| -COPY --chown=fast_llm ./Megatron-LM Megatron-LM |
29 |
| -COPY --chown=fast_llm ./examples examples |
30 |
| -COPY --chown=fast_llm ./tests tests |
31 |
| -COPY --chown=fast_llm ./tools tools |
| 31 | +# Install dependencies within the virtual environment. |
| 32 | +RUN pip install --no-cache-dir --no-build-isolation -e ".[CORE,OPTIONAL,DEV]" |
32 | 33 |
|
33 |
| -# Copy the main source code for Fast-LLM |
34 |
| -COPY --exclude=./fast_llm/csrc/ --chown=fast_llm ./fast_llm/ fast_llm/ |
| 34 | +# Copy the remaining source code with universal write permissions. |
| 35 | +COPY --chmod=777 ./Megatron-LM Megatron-LM |
| 36 | +COPY --chmod=777 ./examples examples |
| 37 | +COPY --chmod=777 ./tests tests |
| 38 | +COPY --chmod=777 ./tools tools |
| 39 | +COPY --chmod=777 --exclude=./fast_llm/csrc/ ./fast_llm/ fast_llm/ |
0 commit comments