| 
1 | 1 | # SimpleTuner needs CU141  | 
2 | 2 | FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04  | 
3 | 3 | 
 
  | 
4 |  | -# /workspace is the default volume for Runpod & other hosts  | 
5 |  | -WORKDIR /workspace  | 
6 |  | - | 
7 |  | -# Update apt-get  | 
8 |  | -RUN apt-get update -y  | 
 | 4 | +ARG PYTHON_VERSION=3.11  | 
9 | 5 | 
 
  | 
10 |  | -# Prevents different commands from being stuck by waiting  | 
11 |  | -# on user input during build  | 
12 |  | -ENV DEBIAN_FRONTEND noninteractive  | 
 | 6 | +# Prevent commands from blocking for input during build  | 
 | 7 | +ENV DEBIAN_FRONTEND=noninteractive  | 
13 | 8 | 
 
  | 
14 |  | -# Install libg dependencies  | 
15 |  | -RUN apt install libgl1-mesa-glx -y  | 
16 |  | -RUN apt-get install 'ffmpeg'\  | 
17 |  | -    'libsm6'\  | 
18 |  | -    'libxext6'  -y  | 
19 |  | - | 
20 |  | -# Install misc unix libraries  | 
21 |  | -RUN apt-get install -y --no-install-recommends openssh-server \  | 
22 |  | -                                               openssh-client \  | 
23 |  | -                                               git \  | 
24 |  | -                                               git-lfs \  | 
25 |  | -                                               wget \  | 
26 |  | -                                               curl \  | 
27 |  | -                                               tmux \  | 
28 |  | -                                               tldr \  | 
29 |  | -                                               nvtop \  | 
30 |  | -                                               vim \  | 
31 |  | -                                               rsync \  | 
32 |  | -                                               net-tools \  | 
33 |  | -                                               less \  | 
34 |  | -                                               iputils-ping \  | 
35 |  | -                                               7zip \  | 
36 |  | -                                               zip \  | 
37 |  | -                                               unzip \  | 
38 |  | -                                               htop \  | 
39 |  | -                                               inotify-tools  | 
 | 9 | +# /workspace is the default volume for Runpod & other hosts  | 
 | 10 | +WORKDIR /workspace  | 
40 | 11 | 
 
  | 
41 |  | -# Set up git to support LFS, and to store credentials; useful for Huggingface Hub  | 
 | 12 | +# Base system dependencies (including Python ${PYTHON_VERSION} toolchain)  | 
 | 13 | +RUN apt-get update -y && \  | 
 | 14 | +    apt-get install -y --no-install-recommends \  | 
 | 15 | +        build-essential \  | 
 | 16 | +        ca-certificates \  | 
 | 17 | +        curl \  | 
 | 18 | +        ffmpeg \  | 
 | 19 | +        git \  | 
 | 20 | +        git-lfs \  | 
 | 21 | +        htop \  | 
 | 22 | +        inotify-tools \  | 
 | 23 | +        iputils-ping \  | 
 | 24 | +        less \  | 
 | 25 | +        libgl1-mesa-glx \  | 
 | 26 | +        libsm6 \  | 
 | 27 | +        libxext6 \  | 
 | 28 | +        libopenmpi-dev \  | 
 | 29 | +        net-tools \  | 
 | 30 | +        nvtop \  | 
 | 31 | +        openmpi-bin \  | 
 | 32 | +        openssh-client \  | 
 | 33 | +        openssh-server \  | 
 | 34 | +        p7zip-full \  | 
 | 35 | +        python${PYTHON_VERSION} \  | 
 | 36 | +        python${PYTHON_VERSION}-dev \  | 
 | 37 | +        python${PYTHON_VERSION}-venv \  | 
 | 38 | +        rsync \  | 
 | 39 | +        tmux \  | 
 | 40 | +        tldr \  | 
 | 41 | +        unzip \  | 
 | 42 | +        vim \  | 
 | 43 | +        wget \  | 
 | 44 | +        zip && \  | 
 | 45 | +    rm -rf /var/lib/apt/lists/*  | 
 | 46 | + | 
 | 47 | +# Configure git to support LFS and credential storage  | 
42 | 48 | RUN git config --global credential.helper store && \  | 
43 | 49 |     git lfs install  | 
44 | 50 | 
 
  | 
45 |  | -# Install Python VENV  | 
46 |  | -RUN apt-get install -y python3.10-venv  | 
 | 51 | +# Create a dedicated virtual environment with the requested Python version  | 
 | 52 | +RUN python${PYTHON_VERSION} -m venv /opt/venv && \  | 
 | 53 | +    /opt/venv/bin/pip install --upgrade pip setuptools wheel  | 
 | 54 | + | 
 | 55 | +# Use the virtual environment for all subsequent Python work  | 
 | 56 | +ENV VIRTUAL_ENV=/opt/venv  | 
 | 57 | +ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"  | 
47 | 58 | 
 
  | 
48 | 59 | # Ensure SSH access. Not needed for Runpod but is required on Vast and other Docker hosts  | 
49 | 60 | EXPOSE 22/tcp  | 
50 | 61 | 
 
  | 
51 |  | -# Python  | 
52 |  | -RUN apt-get update -y && apt-get install -y python3 python3-pip  | 
53 |  | -RUN python3 -m pip install pip --upgrade  | 
54 |  | - | 
55 |  | -# HF  | 
 | 62 | +# HuggingFace cache location and platform hint for setup.py  | 
56 | 63 | ENV HF_HOME=/workspace/huggingface  | 
 | 64 | +ENV SIMPLETUNER_PLATFORM=cuda  | 
57 | 65 | 
 
  | 
58 |  | -RUN pip3 install "huggingface_hub[cli]"  | 
59 |  | - | 
60 |  | -# WanDB  | 
61 |  | -RUN pip3 install wandb  | 
 | 66 | +# Install supporting CLIs ahead of the project install  | 
 | 67 | +RUN pip install --no-cache-dir "huggingface_hub[cli]" wandb  | 
62 | 68 | 
 
  | 
63 |  | -# Clone SimpleTuner  | 
64 |  | -RUN git clone https://github.com/bghira/SimpleTuner --branch release  | 
65 |  | -# RUN git clone https://github.com/bghira/SimpleTuner --branch main # Uncomment to use latest (possibly unstable) version  | 
 | 69 | +# Install MPI bindings needed for CUDA multi-node support  | 
 | 70 | +RUN pip install --no-cache-dir mpi4py  | 
66 | 71 | 
 
  | 
67 |  | -# Install SimpleTuner  | 
68 |  | -RUN pip3 install poetry  | 
69 |  | -RUN cd SimpleTuner && python3 -m venv .venv && poetry install --no-root  | 
70 |  | -RUN chmod +x SimpleTuner/train.sh  | 
 | 72 | +# Install SimpleTuner from PyPI to match published releases  | 
 | 73 | +RUN pip install --no-cache-dir simpletuner  | 
71 | 74 | 
 
  | 
72 | 75 | # Copy start script with exec permissions  | 
73 | 76 | COPY --chmod=755 docker-start.sh /start.sh  | 
74 | 77 | 
 
  | 
 | 78 | +# Ensure we remain in the default workspace location  | 
 | 79 | +WORKDIR /workspace  | 
 | 80 | + | 
75 | 81 | # Dummy entrypoint  | 
76 | 82 | ENTRYPOINT [ "/start.sh" ]  | 
0 commit comments