Spaces:
Sleeping
Sleeping
Add new dockerfiles for various use cases
Browse files- Dockerfile +10 -53
- Dockerfile.base +56 -0
- Dockerfile.full +88 -0
Dockerfile
CHANGED
@@ -1,48 +1,13 @@
|
|
1 |
# Custom docker image for DeTikZify. The default HF Spaces GPU image installs a
|
2 |
# tex live version that is too old for our needs, so we install the correct one
|
3 |
-
# ourselves.
|
|
|
|
|
|
|
4 |
|
5 |
## system setup
|
6 |
# -----------------------------------------------------------------------------
|
7 |
-
FROM
|
8 |
-
|
9 |
-
ARG DEBIAN_FRONTEND=noninteractive
|
10 |
-
|
11 |
-
Run apt update && apt install -y \
|
12 |
-
ghostscript \
|
13 |
-
poppler-utils \
|
14 |
-
git \
|
15 |
-
make \
|
16 |
-
build-essential \
|
17 |
-
libssl-dev \
|
18 |
-
zlib1g-dev \
|
19 |
-
libbz2-dev \
|
20 |
-
libreadline-dev \
|
21 |
-
libsqlite3-dev \
|
22 |
-
wget \
|
23 |
-
curl \
|
24 |
-
llvm \
|
25 |
-
libncursesw5-dev \
|
26 |
-
xz-utils \
|
27 |
-
tk-dev \
|
28 |
-
libxml2-dev \
|
29 |
-
libxmlsec1-dev \
|
30 |
-
libffi-dev \
|
31 |
-
liblzma-dev \
|
32 |
-
ffmpeg \
|
33 |
-
libsm6 \
|
34 |
-
libxext6 \
|
35 |
-
cmake \
|
36 |
-
libgl1-mesa-glx \
|
37 |
-
sudo
|
38 |
-
|
39 |
-
# install tex live 2023
|
40 |
-
ENV PATH=/opt/texbin:$PATH
|
41 |
-
|
42 |
-
RUN curl -LO https://github.com/scottkosty/install-tl-ubuntu/raw/master/install-tl-ubuntu \
|
43 |
-
&& chmod +x ./install-tl-ubuntu \
|
44 |
-
&& ./install-tl-ubuntu --repository 'https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2023/tlnet-final'\
|
45 |
-
&& rm ./install-tl-ubuntu
|
46 |
|
47 |
## setup user
|
48 |
# -----------------------------------------------------------------------------
|
@@ -55,15 +20,6 @@ WORKDIR $HOME/app
|
|
55 |
|
56 |
## install python dependencies
|
57 |
# -----------------------------------------------------------------------------
|
58 |
-
|
59 |
-
# install pyenv
|
60 |
-
ENV PYENV_ROOT=/opt/pyenv
|
61 |
-
ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
|
62 |
-
|
63 |
-
RUN curl https://pyenv.run | bash \
|
64 |
-
&& chown -R root:users $PYENV_ROOT \
|
65 |
-
&& chmod -R g+w $PYENV_ROOT
|
66 |
-
|
67 |
RUN pyenv install 3.11 \
|
68 |
&& pyenv global 3.11 \
|
69 |
&& pyenv rehash \
|
@@ -75,13 +31,14 @@ RUN pyenv install 3.11 \
|
|
75 |
RUN chown -R user $HOME/app
|
76 |
COPY --chown=user . $HOME/app
|
77 |
|
78 |
-
##
|
79 |
# -----------------------------------------------------------------------------
|
80 |
-
RUN
|
81 |
&& chown -R user $HOME/.cache
|
82 |
|
83 |
-
## launch app
|
84 |
# -----------------------------------------------------------------------------
|
85 |
USER user
|
86 |
|
87 |
-
CMD
|
|
|
|
1 |
# Custom docker image for DeTikZify. The default HF Spaces GPU image installs a
|
2 |
# tex live version that is too old for our needs, so we install the correct one
|
3 |
+
# ourselves. This simplified Dockerfile is based on an intermediate image
|
4 |
+
# (./Dockerfile.base) that already has Tex Live and pyenv installed, thereby
|
5 |
+
# greatly improving build time. It also defers preloading of detikzify models
|
6 |
+
# to runtime to avoid OOM errors.
|
7 |
|
8 |
## system setup
|
9 |
# -----------------------------------------------------------------------------
|
10 |
+
FROM registry.hf.space/nllg-detikzify:gpu-7ec758b-nmbqkl3l
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
## setup user
|
13 |
# -----------------------------------------------------------------------------
|
|
|
20 |
|
21 |
## install python dependencies
|
22 |
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
RUN pyenv install 3.11 \
|
24 |
&& pyenv global 3.11 \
|
25 |
&& pyenv rehash \
|
|
|
31 |
RUN chown -R user $HOME/app
|
32 |
COPY --chown=user . $HOME/app
|
33 |
|
34 |
+
## prepare cache for models
|
35 |
# -----------------------------------------------------------------------------
|
36 |
+
RUN mkdir -p $HOME/.cache \
|
37 |
&& chown -R user $HOME/.cache
|
38 |
|
39 |
+
## preload detikzify-v2.5 and launch app
|
40 |
# -----------------------------------------------------------------------------
|
41 |
USER user
|
42 |
|
43 |
+
CMD huggingface-cli download nllg/detikzify-v2.5-8b \
|
44 |
+
&& python app.py
|
Dockerfile.base
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Custom docker image for DeTikZify. The default HF Spaces GPU image installs a
|
2 |
+
# tex live version that is too old for our needs, so we install the correct one
|
3 |
+
# ourselves. This Dockerfile builds the base image for the simplified
|
4 |
+
# Dockerfile (./Dockerfile).
|
5 |
+
|
6 |
+
## system setup
|
7 |
+
# -----------------------------------------------------------------------------
|
8 |
+
FROM nvcr.io/nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
|
9 |
+
|
10 |
+
ARG DEBIAN_FRONTEND=noninteractive
|
11 |
+
|
12 |
+
RUN apt update && apt install -y \
|
13 |
+
ghostscript \
|
14 |
+
poppler-utils \
|
15 |
+
git \
|
16 |
+
make \
|
17 |
+
build-essential \
|
18 |
+
libssl-dev \
|
19 |
+
zlib1g-dev \
|
20 |
+
libbz2-dev \
|
21 |
+
libreadline-dev \
|
22 |
+
libsqlite3-dev \
|
23 |
+
wget \
|
24 |
+
curl \
|
25 |
+
llvm \
|
26 |
+
libncursesw5-dev \
|
27 |
+
xz-utils \
|
28 |
+
tk-dev \
|
29 |
+
libxml2-dev \
|
30 |
+
libxmlsec1-dev \
|
31 |
+
libffi-dev \
|
32 |
+
liblzma-dev \
|
33 |
+
ffmpeg \
|
34 |
+
libsm6 \
|
35 |
+
libxext6 \
|
36 |
+
cmake \
|
37 |
+
libgl1-mesa-glx \
|
38 |
+
sudo
|
39 |
+
|
40 |
+
## install tex live 2023
|
41 |
+
# -----------------------------------------------------------------------------
|
42 |
+
ENV PATH=/opt/texbin:$PATH
|
43 |
+
|
44 |
+
RUN curl -LO https://github.com/scottkosty/install-tl-ubuntu/raw/master/install-tl-ubuntu \
|
45 |
+
&& chmod +x ./install-tl-ubuntu \
|
46 |
+
&& ./install-tl-ubuntu --repository 'https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2023/tlnet-final'\
|
47 |
+
&& rm ./install-tl-ubuntu
|
48 |
+
|
49 |
+
## install pyenv
|
50 |
+
# -----------------------------------------------------------------------------
|
51 |
+
ENV PYENV_ROOT=/opt/pyenv
|
52 |
+
ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
|
53 |
+
|
54 |
+
RUN curl https://pyenv.run | bash \
|
55 |
+
&& chown -R root:users $PYENV_ROOT \
|
56 |
+
&& chmod -R g+w $PYENV_ROOT
|
Dockerfile.full
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Custom docker image for DeTikZify. The default HF Spaces GPU image installs a
|
2 |
+
# tex live version that is too old for our needs, so we install the correct one
|
3 |
+
# ourselves. This is the full Dockerfile which installs TeX Live from scratch
|
4 |
+
# which could take a while to complete.
|
5 |
+
|
6 |
+
## system setup
|
7 |
+
# -----------------------------------------------------------------------------
|
8 |
+
FROM nvcr.io/nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
|
9 |
+
|
10 |
+
ARG DEBIAN_FRONTEND=noninteractive
|
11 |
+
|
12 |
+
RUN apt update && apt install -y \
|
13 |
+
ghostscript \
|
14 |
+
poppler-utils \
|
15 |
+
git \
|
16 |
+
make \
|
17 |
+
build-essential \
|
18 |
+
libssl-dev \
|
19 |
+
zlib1g-dev \
|
20 |
+
libbz2-dev \
|
21 |
+
libreadline-dev \
|
22 |
+
libsqlite3-dev \
|
23 |
+
wget \
|
24 |
+
curl \
|
25 |
+
llvm \
|
26 |
+
libncursesw5-dev \
|
27 |
+
xz-utils \
|
28 |
+
tk-dev \
|
29 |
+
libxml2-dev \
|
30 |
+
libxmlsec1-dev \
|
31 |
+
libffi-dev \
|
32 |
+
liblzma-dev \
|
33 |
+
ffmpeg \
|
34 |
+
libsm6 \
|
35 |
+
libxext6 \
|
36 |
+
cmake \
|
37 |
+
libgl1-mesa-glx \
|
38 |
+
sudo
|
39 |
+
|
40 |
+
# install tex live 2023
|
41 |
+
ENV PATH=/opt/texbin:$PATH
|
42 |
+
|
43 |
+
RUN curl -LO https://github.com/scottkosty/install-tl-ubuntu/raw/master/install-tl-ubuntu \
|
44 |
+
&& chmod +x ./install-tl-ubuntu \
|
45 |
+
&& ./install-tl-ubuntu --repository 'https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2023/tlnet-final'\
|
46 |
+
&& rm ./install-tl-ubuntu
|
47 |
+
|
48 |
+
## setup user
|
49 |
+
# -----------------------------------------------------------------------------
|
50 |
+
RUN useradd -m -G users -u 1000 user
|
51 |
+
|
52 |
+
ENV HOME=/home/user \
|
53 |
+
PATH=/home/user/.local/bin:$PATH
|
54 |
+
|
55 |
+
WORKDIR $HOME/app
|
56 |
+
|
57 |
+
## install python dependencies
|
58 |
+
# -----------------------------------------------------------------------------
|
59 |
+
|
60 |
+
# install pyenv
|
61 |
+
ENV PYENV_ROOT=/opt/pyenv
|
62 |
+
ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
|
63 |
+
|
64 |
+
RUN curl https://pyenv.run | bash \
|
65 |
+
&& chown -R root:users $PYENV_ROOT \
|
66 |
+
&& chmod -R g+w $PYENV_ROOT
|
67 |
+
|
68 |
+
RUN pyenv install 3.11 \
|
69 |
+
&& pyenv global 3.11 \
|
70 |
+
&& pyenv rehash \
|
71 |
+
&& pip install --no-cache-dir --upgrade setuptools wheel \
|
72 |
+
&& pip install --no-cache-dir 'detikzify[legacy] @ git+https://github.com/potamides/DeTikZify' \
|
73 |
+
&& pip install --no-cache-dir flash-attn --no-build-isolation \
|
74 |
+
&& pip install --no-cache-dir spaces
|
75 |
+
|
76 |
+
RUN chown -R user $HOME/app
|
77 |
+
COPY --chown=user . $HOME/app
|
78 |
+
|
79 |
+
## preload v2 models
|
80 |
+
# -----------------------------------------------------------------------------
|
81 |
+
RUN huggingface-cli download nllg/detikzify-v2.5-8b \
|
82 |
+
&& chown -R user $HOME/.cache
|
83 |
+
|
84 |
+
## launch app
|
85 |
+
# -----------------------------------------------------------------------------
|
86 |
+
USER user
|
87 |
+
|
88 |
+
CMD ["python", "app.py"]
|