forked from bmaltais/kohya-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
126 lines (110 loc) · 3.14 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Stage 1: Base
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 as base
ARG KOHYA_VERSION=v21.8.8
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Europe/Zurich \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=on \
SHELL=/bin/bash
USER root
RUN apt-get clean
# Install Ubuntu packages
RUN apt update && \
apt -y upgrade && \
apt install -y --no-install-recommends \
software-properties-common \
python3.10-venv \
python3-pip \
python3-tk \
bash \
apt-utils \
dos2unix \
git \
ncdu \
nginx \
net-tools \
openssh-server \
libglib2.0-0 \
libsm6 \
libgl1 \
libxrender1 \
libxext6 \
ffmpeg \
glances \
wget \
curl \
psmisc \
nano \
rsync \
vim \
fish \
zip \
unzip \
mc \
p7zip-full \
htop \
pkg-config \
libcairo2-dev \
libgoogle-perftools4 libtcmalloc-minimal4 \
apt-transport-https ca-certificates && \
update-ca-certificates && \
apt clean && \
rm -rf /var/lib/apt/lists/* && \
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
# Set Python
RUN ln -s /usr/bin/python3.10 /usr/bin/python
# Stage 2: Install kohya_ss and python modules
FROM base as kohya_ss_setup
# Create workspace working directory
WORKDIR /
# Install Kohya_ss
RUN git clone https://github.com/bmaltais/kohya_ss.git
WORKDIR /kohya_ss
RUN git checkout ${KOHYA_VERSION} && \
python3 -m venv --system-site-packages venv && \
source venv/bin/activate && \
pip3 install torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 && \
pip3 install xformers==0.0.20 \
bitsandbytes==0.41.1 \
tensorboard==2.12.3 \
tensorflow==2.12.0 \
wheel \
tensorrt && \
pip3 install -r requirements.txt && \
pip3 install . && \
deactivate
#get SDXL model
RUN mkdir -p /kohya_ss/model/
RUN wget -O /kohya_ss/model/sd_xl_base_1.0.safetensors https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors
# Copy local training data to the container
COPY training_data/ /characters_raw
# Install Jupyter
RUN pip3 install -U --no-cache-dir jupyterlab \
jupyterlab_widgets \
ipykernel \
ipywidgets \
gdown
# Install runpodctl
RUN wget https://github.com/runpod/runpodctl/releases/download/v1.10.0/runpodctl-linux-amd -O runpodctl && \
chmod a+x runpodctl && \
mv runpodctl /usr/local/bin
# NGINX Proxy
COPY nginx/nginx.conf /etc/nginx/nginx.conf
COPY nginx/502.html /usr/share/nginx/html/502.html
COPY nginx/template-readme.md /usr/share/nginx/html/README.md
# Copy cutom scripts
COPY train.py /
COPY assets_prep.py /
COPY data_validation.py /
COPY train.sh /
COPY zipandsend.py /
# Set up the container startup script
WORKDIR /
COPY pre_start.sh start.sh fix_venv.sh accelerate.yaml ./
RUN chmod +x /start.sh && \
chmod +x /pre_start.sh && \
chmod +x /fix_venv.sh
# Start the container
SHELL ["/bin/bash", "--login", "-c"]
CMD [ "/start.sh" ]