[Docker support] enabling docker, adding description to readme#134
[Docker support] enabling docker, adding description to readme#134JustinGuese wants to merge 12 commits intoCompVis:mainfrom
Conversation
| # trigger first download to prevent re-downloading in the future | ||
| # the script will fail as we do not have the weights yet, therefore the exit 0 | ||
| RUN python scripts/txt2img.py; exit 0 |
There was a problem hiding this comment.
I've been wondering how to do this, is there really no better way to download the deps?
There was a problem hiding this comment.
yeah it must be simple code somewhere, didn't find it so far though
must be some tqdm part, maybe:
stable-diffusion/ldm/models/diffusion/ddpm.py
Line 532 in 69ae4b3
Co-authored-by: eggplants <w10776e8w@yahoo.co.jp>
Co-authored-by: eggplants <w10776e8w@yahoo.co.jp>
Co-authored-by: eggplants <w10776e8w@yahoo.co.jp>
|
thx @eggplants the weight(th)s gets me every time |
|
okay the part that does not get initialized yet is so I will try to add that to the docker image as well... it's already like 10 GB, so 14 GB wouldn't be to different neither :D it's absurd yes |
Co-authored-by: Harrison Kiang <hkiang01@gmail.com>
hkiang01
left a comment
There was a problem hiding this comment.
Optimizations re: Docker's build cache
| RUN ln -s /root/miniconda3/bin/conda /usr/local/bin/conda | ||
| RUN conda update -y conda | ||
| # i am using git clone instead during development of this dockerfile | ||
| COPY . /app/ |
There was a problem hiding this comment.
So as to take advantage of Docker's build cache, COPYs should be towards the bottom of the Dockerfile as possible. In this case, the only files required before the RUN conda env create... layer is the environment.yml and setup.py.
| COPY . /app/ | |
| COPY environment.yml setup.py ./ |
There was a problem hiding this comment.
need to check if really only the environment.yml is needed, I think the .yml uses the setup.py to build the local package as well, that is why I thought it's needed as well. will check it out though
| RUN wget https://github.com/DagnyT/hardnet/raw/master/pretrained/train_liberty_with_aug/checkpoint_liberty_with_aug.pth -P /root/.cache/torch/hub/checkpoints/checkpoint_liberty_with_aug.pth | ||
| # and now just grab the weights as well | ||
| RUN wget https://www.googleapis.com/storage/v1/b/aai-blog-files/o/sd-v1-4.ckpt?alt=media -P weights/sd-v1-4.ckpt | ||
| CMD [ "python", "scripts/txt2img.py", \ |
There was a problem hiding this comment.
Along with the other suggestion for COPY, to make sure the files are still available, we can move the original COPY towards the bottom, here
| CMD [ "python", "scripts/txt2img.py", \ | |
| COPY . /app/ | |
| CMD [ "python", "scripts/txt2img.py", \ |
|
@JustinGuese, would you be willing to add this to https://github.com/lstein/stable-diffusion? |
|
@magnusviri can do |
|
@magnusviri i added it to lstein's version: invoke-ai/InvokeAI#560 |
| RUN rm /usr/local/bin/python | ||
| RUN ln -s /root/miniconda3/envs/ldm/bin/python /usr/local/bin/python |
There was a problem hiding this comment.
Have you considered this simpler alternative?
| RUN rm /usr/local/bin/python | |
| RUN ln -s /root/miniconda3/envs/ldm/bin/python /usr/local/bin/python | |
| ENV PATH /root/miniconda3/envs/ldm/bin:$PATH |
There was a problem hiding this comment.
yeah at least for me it didn't work when calling python later on... but feel free to try it out
There was a problem hiding this comment.
you can also look at PYTHONPATH
| RUN rm /usr/local/bin/python | |
| RUN ln -s /root/miniconda3/envs/ldm/bin/python /usr/local/bin/python | |
| ENV PYTHONPATH=/root/miniconda3/envs/ldm |
| FROM python:3.8-slim | ||
| RUN apt update && apt install -y wget git libglib2.0-0 libsm6 libxext6 libxrender-dev | ||
| RUN apt clean && rm -rf /var/lib/apt/lists/* | ||
| # RUN useradd -ms /bin/bash stablediff | ||
| # install conda | ||
| RUN wget \ | ||
| https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \ | ||
| && mkdir /root/.conda \ | ||
| && bash Miniconda3-latest-Linux-x86_64.sh -b \ | ||
| && rm -f Miniconda3-latest-Linux-x86_64.sh \ | ||
| && echo PATH="/root/miniconda3/bin":$PATH >> .bashrc | ||
| RUN chmod +x /root/miniconda3/bin/conda | ||
| RUN ln -s /root/miniconda3/bin/conda /usr/local/bin/conda | ||
| RUN conda update -y conda |
There was a problem hiding this comment.
The official continuumio/miniconda3 container images would spare a few lines
| FROM python:3.8-slim | |
| RUN apt update && apt install -y wget git libglib2.0-0 libsm6 libxext6 libxrender-dev | |
| RUN apt clean && rm -rf /var/lib/apt/lists/* | |
| # RUN useradd -ms /bin/bash stablediff | |
| # install conda | |
| RUN wget \ | |
| https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \ | |
| && mkdir /root/.conda \ | |
| && bash Miniconda3-latest-Linux-x86_64.sh -b \ | |
| && rm -f Miniconda3-latest-Linux-x86_64.sh \ | |
| && echo PATH="/root/miniconda3/bin":$PATH >> .bashrc | |
| RUN chmod +x /root/miniconda3/bin/conda | |
| RUN ln -s /root/miniconda3/bin/conda /usr/local/bin/conda | |
| RUN conda update -y conda | |
| FROM continuumio/miniconda3 |
There was a problem hiding this comment.
i was hesitant about that because it was last updated 3 months ago... but yeah maybe using that and just do a apt update upgrade...?
|
Fun fact: 3 of the dependencies that you install store files in |
Co-authored-by: Helio Machado <0x2b3bfa0+git@googlemail.com>
Co-authored-by: Shenghang Tsai <jackalcooper@gmail.com>
Co-authored-by: Shenghang Tsai <jackalcooper@gmail.com>
Co-authored-by: Shenghang Tsai <jackalcooper@gmail.com>
feel free to edit the dockerfile, or you can name me the URLs of them and the paths where they are supposed to be and I will add it ;) |
|
@JustinGuese Will do when I have time. It's the CLIP and taming-transform dependency that make files in |
|
Oh also, don't run |
adding docker support and a proposal for usage in the readme