-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
76 lines (63 loc) · 2.66 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
################################################################################
# Dockerfile that builds runtime environment
# for AUTOMATIC1111/stable-diffusion-webui.
################################################################################
FROM opensuse/tumbleweed:latest
LABEL maintainer="code@yanwk.fun"
WORKDIR /root
RUN --mount=type=cache,target=/var/cache/zypp \
set -eu \
&& zypper install --no-confirm \
python311 python311-pip \
python311-wheel python311-setuptools python311-numpy \
python311-devel python311-Cython \
gcc-c++ cmake \
shadow git aria2 \
gperftools-devel libgthread-2_0-0 Mesa-libGL1 \
libtcmalloc4 libglvnd \
&& rm /usr/lib64/python3.11/EXTERNALLY-MANAGED
# Use TCMALLOC from gperftools.
ENV LD_PRELOAD=libtcmalloc.so
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
--upgrade pip
# Install xFormers (stable version, will specify PyTorch version)
# and Torchvision + Torchaudio (will downgrade to match xFormers' PyTorch version)
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
xformers torchvision torchaudio
# All remaining deps are described in txt
COPY ["requirements.txt","/root/"]
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r /root/requirements.txt
# Fix for libs (.so files)
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}\
:/usr/lib64/python3.11/site-packages/torch/lib\
:/usr/lib/python3.11/site-packages/nvidia/cuda_cupti/lib\
:/usr/lib/python3.11/site-packages/nvidia/cuda_runtime/lib\
:/usr/lib/python3.11/site-packages/nvidia/cudnn/lib\
:/usr/lib/python3.11/site-packages/nvidia/cufft/lib"
# More libs (not necessary, just in case)
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}\
:/usr/lib/python3.11/site-packages/nvidia/cublas/lib\
:/usr/lib/python3.11/site-packages/nvidia/cuda_nvrtc/lib\
:/usr/lib/python3.11/site-packages/nvidia/curand/lib\
:/usr/lib/python3.11/site-packages/nvidia/cusolver/lib\
:/usr/lib/python3.11/site-packages/nvidia/cusparse/lib\
:/usr/lib/python3.11/site-packages/nvidia/nccl/lib\
:/usr/lib/python3.11/site-packages/nvidia/nvjitlink/lib\
:/usr/lib/python3.11/site-packages/nvidia/nvtx/lib"
# Create a low-privilege user.
RUN printf 'CREATE_MAIL_SPOOL=no' > /etc/default/useradd \
&& mkdir -p /home/runner /home/scripts \
&& groupadd runner \
&& useradd runner -g runner -d /home/runner \
&& chown runner:runner /home/runner /home/scripts
COPY --chown=runner:runner scripts/. /home/scripts/
USER runner:runner
VOLUME /home/runner
WORKDIR /home/runner
ENV CLI_ARGS=""
EXPOSE 7860
STOPSIGNAL SIGINT
CMD bash /home/scripts/entrypoint.sh