-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
83 lines (69 loc) · 2.48 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Stage 1: Base Image
ARG BASE_IMAGE=ashleykza/runpod-base:2.1.1-python3.10-cuda12.1.1-torch2.1.2
FROM ${BASE_IMAGE} AS base
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Europe/London \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=on \
SHELL=/bin/bash
# Add SDXL base model
# This needs to already have been downloaded:
# wget https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors
RUN mkdir -p /sd-models
COPY sd_xl_base_1.0.safetensors /sd-models/sd_xl_base_1.0.safetensors
# Create workspace working directory
WORKDIR /
# Stage 2: Kohya_ss Installation
FROM base AS kohya-install
ARG KOHYA_VERSION
RUN git clone https://github.com/bmaltais/kohya_ss.git /kohya_ss && \
cd /kohya_ss && \
git checkout ${KOHYA_VERSION} && \
git submodule update --init --recursive
ARG INDEX_URL
ARG TORCH_VERSION
ARG XFORMERS_VERSION
WORKDIR /kohya_ss
COPY kohya_ss/requirements* ./
RUN python3 -m venv --system-site-packages /venv && \
source /venv/bin/activate && \
pip3 install torch==${TORCH_VERSION} torchvision torchaudio --index-url ${INDEX_URL} && \
pip3 install xformers==${XFORMERS_VERSION} --index-url ${INDEX_URL} && \
pip3 install bitsandbytes==0.43.0 \
tensorboard==2.15.2 tensorflow==2.15.0.post1 \
wheel packaging tensorrt && \
pip3 install tensorflow[and-cuda] && \
pip3 install -r requirements.txt && \
deactivate
# Stage 3: Tensorboard Installation
FROM kohya-install AS tensorboard-install
WORKDIR /
RUN pip3 uninstall -y tensorboard tb-nightly && \
pip3 install tensorboard==2.15.2 tensorflow==2.15.0.post1
# Stage 4: Application Manager Installation
FROM tensorboard-install AS appmanager-install
ARG APP_MANAGER_VERSION
WORKDIR /
RUN git clone https://github.com/ashleykleynhans/app-manager.git /app-manager && \
cd /app-manager && \
git checkout tags/${APP_MANAGER_VERSION} && \
npm install
COPY app-manager/config.json /app-manager/public/config.json
COPY --chmod=755 app-manager/*.sh /app-manager/scripts/
# Stage 5: Finalise Image
FROM appmanager-install AS final
# Remove existing SSH host keys
RUN rm -f /etc/ssh/ssh_host_*
# NGINX Proxy
COPY nginx/nginx.conf /etc/nginx/nginx.conf
# Set template version
ARG RELEASE
ENV TEMPLATE_VERSION=${RELEASE}
# Copy the scripts
COPY --chmod=755 scripts/* ./
# Copy the accelerate configuration
COPY kohya_ss/accelerate.yaml ./
# Start the container
SHELL ["/bin/bash", "--login", "-c"]
CMD [ "/start.sh" ]