-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile.lama
54 lines (43 loc) · 2.27 KB
/
Dockerfile.lama
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
FROM nvidia/cuda:11.3.1-base-ubuntu20.04
SHELL ["/bin/bash", "-c"]
WORKDIR /root
RUN apt update \
&& apt install --no-install-recommends -y curl wget git libglib2.0-0 libgl1 build-essential fonts-dejavu \
&& apt-get clean
VOLUME /root/.cache
VOLUME /res
ENV PYTHONUNBUFFERED=1
ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=7860
EXPOSE 7860
ENV BASH_ENV=/etc/profile
ENV CONDA_DEFAULT_ENV=base
RUN mkdir ~/.conda \
&& wget https://repo.anaconda.com/miniconda/Miniconda3-py38_4.12.0-Linux-x86_64.sh -O ~/miniconda.sh -q \
&& mkdir -p /opt \
&& bash ~/miniconda.sh -b -p /opt/conda \
&& rm ~/miniconda.sh \
&& ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh \
&& echo ". /opt/conda/etc/profile.d/conda.sh" >> /etc/profile \
&& echo "conda activate \$CONDA_DEFAULT_ENV" >> /etc/profile \
&& echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc \
&& echo "conda activate \$CONDA_DEFAULT_ENV" >> ~/.bashrc \
&& find /opt/conda/ -follow -type f -name '*.a' -delete \
&& find /opt/conda/ -follow -type f -name '*.js.map' -delete \
&& /opt/conda/bin/conda clean -afy
ARG PIP_VERSION
RUN conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch
RUN pip install lama-cleaner==$PIP_VERSION ftfy==6.1.1 spacy==3.4.3
RUN echo -e "#!/bin/bash\nset -e\n" > /root/bootstrap.sh \
&& echo -e "if [ ! -z \"\$@\" ]; then" >> /root/bootstrap.sh \
&& echo -e " exec \"\$@\"" >> /root/bootstrap.sh \
&& echo -e "elif [ -d "/root/.cache/huggingface/diffusers/models--runwayml--stable-diffusion-inpainting/refs" ]; then" >> /root/bootstrap.sh \
&& echo -e " lama-cleaner --model=sd1.5 --host=0.0.0.0 --port=8080 --sd-run-local" >> /root/bootstrap.sh \
&& echo -e "elif [ ! -z "\$HUGGINGFACE_TOKEN" ]; then" >> /root/bootstrap.sh \
&& echo -e " lama-cleaner --model=sd1.5 --host=0.0.0.0 --port=8080 --hf_access_token=\$HUGGINGFACE_TOKEN" >> /root/bootstrap.sh \
&& echo -e "else" >> /root/bootstrap.sh \
&& echo -e " echo \"Warning: SD is not in use because a Hugging Face token was not specified in the environment!\"" >> /root/bootstrap.sh \
&& echo -e " lama-cleaner --model=lama --host=0.0.0.0 --port=8080" >> /root/bootstrap.sh \
&& echo -e "fi" >> /root/bootstrap.sh \
&& chmod +x /root/bootstrap.sh
ENTRYPOINT ["/root/bootstrap.sh"]