Skip to content

Instantly share code, notes, and snippets.

@craigmayhew
Created September 26, 2022 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigmayhew/a645c3f845d2b53e12a70f5dba914cfd to your computer and use it in GitHub Desktop.
Save craigmayhew/a645c3f845d2b53e12a70f5dba914cfd to your computer and use it in GitHub Desktop.
# docker run -it -v "$PWD":/stable-diffusion/models/ldm/stable-diffusion-v1 ml
FROM ubuntu:22.04
# Updating Ubuntu packages
RUN apt-get update && yes|apt-get upgrade
# Adding git, bzip2 and wget
RUN apt-get install -y bzip2 git wget
# Install stable diffusion
RUN git clone https://github.com/basujindal/stable-diffusion.git && cd stable-diffusion
# Anaconda installing
RUN wget https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh
RUN bash Anaconda3-5.0.1-Linux-x86_64.sh -b
RUN rm Anaconda3-5.0.1-Linux-x86_64.sh
# Set path to conda
ENV PATH /root/anaconda3/bin:$PATH
# Updating Anaconda packages
RUN conda update conda
# activate the environmnet specified in the environment.yml file
RUN cd /stable-diffusion && conda env create -f environment.yaml
RUN cd /stable-diffusion && conda init bash && source ~/.bashrc && conda activate ldm
RUN ln -s /stable-diffusion/models/ldm/stable-diffusion-v1/sd-v1-4.ckpt /stable-diffusion/models/ldm/stable-diffusion-v1/model.ckpt
# MANUAL STEP download https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/blob/main/sd-v1-4.ckpt and place it in the same dir as our Dockerfile
# outside of docker cd to wherever this docker file and the ckpt is
# docker run -it -v "$PWD":/stable-diffusion/models/ldm/stable-diffusion-v1 ml <---- use this to mount the ml folder via docker
# in the anaconda environment run
#CMD cd /stable-diffusion && python optimizedSD/optimized_txt2img.py --prompt "a cat sat on a mat" --H 128 --W 128 --n_samples 2 --ddim_steps 50 --device cpu
# wait for files to appear and copy the files to the mounter dir so you can see them outside docker
#CMD cp -r /stable-diffusion/outputs/txt2img-samples/* /stable-diffusion/models/ldm/stable-diffusion-v1/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment