Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stable diffusion example #1149

Merged

Conversation

sumanthgenz
Copy link
Collaborator

Add a Dockerfile needed to create docker environment to run a stable diffusion web tool on GPU.
Add a yaml to launch an instance with a GPU to run said Dockerfile and run the stable diffusion tool (using ssh with port forwarding).

Copy link
Member

@concretevitamin concretevitamin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sumanthgenz! I tried it out and it works great. Some comments.



resources:
cloud: azure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leave this out? So people have flexibility.

accelerators: V100:1

file_mounts:
/stable_diffusion: ./docker/stable_diffusion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the source (RHS) to .? See the other comment for dir structure.

@@ -0,0 +1,35 @@

# Steps to run this example:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Can we also put them in a README.md? Can even add Step 0: pip install skypilot and point to our Installation docs page. Maybe some title like "Run your own Stable Diffusion UI in the cloud with one click"?

examples/stable_diffusion/
  README.md
  this.yaml
  Dockerfile

Goal is for people to come to this dir, look at README and immediately get started.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, we should move this to examples/stable_diffusion

@@ -0,0 +1,58 @@
# Note: this file is from https://github.com/AbdBarho/stable-diffusion-webui-docker/blob/master/build/Dockerfile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this file has changes on top of the referred to file. Could we describe those changes here? Wondering if we can take that existing Dockerfile and run it with SkyPilot.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docker in the instance cannot compile the original dockerfile from the repo. I removed <<EOF heredoc to fix that, so that was the only change. I will specify that we made that change.

RUN python /info.py /stable-diffusion/frontend/frontend.py

WORKDIR /stable-diffusion
ENV TRANSFORMERS_CACHE=/cache/transformers TORCH_HOME=/cache/torch CLI_ARGS="" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using the Stable Diffusion ckpt sd-v1-4.ckpt, or the models downloaded on L44-46?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using sd-v1-4.ckpt

@concretevitamin
Copy link
Member

In the README, it'd also be great to include some (setting, prompt) combos that generate great-looking pics. (I tried my own prompts and they didn't work out so great.)

Copy link
Collaborator

@romilbhardwaj romilbhardwaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just ran on GCP V100, looks great!

image

image

@@ -0,0 +1,35 @@

# Steps to run this example:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, we should move this to examples/stable_diffusion


run: |
cd stable-diffusion-webui-docker
docker-compose up --build
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the --build required? We already run docker-compose build in setup

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, i will remove it

Comment on lines 21 to 31
# download dev UI version, update the sha below in case you want some other version
# RUN <<EOF
# git clone https://github.com/hlky/stable-diffusion-webui.git
# cd stable-diffusion-webui
# # map to this file: https://github.com/hlky/stable-diffusion-webui/blob/master/.github/sync.yml
# git reset --hard 49e6178fd82ca736f9bbc621c6b12487c300e493
# cp -t /stable-diffusion/scripts/ webui.py relauncher.py txt2img.yaml
# cp -t /stable-diffusion/configs/webui webui.yaml
# cp -t /stable-diffusion/frontend/ frontend/*
# cd / && rm -rf stable-diffusion-webui
# EOF
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not used, should we just remove this? Or maybe make the comments more descriptive - right now its not clear what this code block is for.

Copy link
Collaborator

@romilbhardwaj romilbhardwaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readme looks great! Will be very useful for new users.


2. Run sky launch -c stable-diffusion stable_diffusion_docker.yaml

3. Run ssh -L 7860:localhost:7860 stable-diffusion
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add codeblock formatting:

Run `ssh -L 7860:localhost:7860 stable-diffusion`


1. Install skypilot by following these [instructions](https://skypilot.readthedocs.io/en/latest/getting-started/installation.html)

2. Run sky launch -c stable-diffusion stable_diffusion_docker.yaml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps add a block git clone and cd to this directory:

git clone https://github.com/skypilot-org/skypilot.git && cd examples/stable_diffusion
sky launch -c stable-diffusion stable_diffusion_docker.yaml

The idea is to have a copy-paste-able readme :)

@@ -0,0 +1,33 @@
## Setup

1. Install skypilot by following these [instructions](https://skypilot.readthedocs.io/en/latest/getting-started/installation.html)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Add a period at the end of bullet points that are complete sentences


3. Run ssh -L 7860:localhost:7860 stable-diffusion

4. Open http://localhost:7860/ in browser.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add codeblock formatting:

Open [`http://localhost:7860/`](http://localhost:7860/) in browser.


4. Open http://localhost:7860/ in browser.

5. Type in text prompt and click "Generate"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Add a period at the end of bullet points that are complete sentences

examples/stable_diffusion/README.md Show resolved Hide resolved
4. Open http://localhost:7860/ in browser.

5. Type in text prompt and click "Generate"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add:

6. Once you are done, run `sky down stable-diffusion` to terminate the VM.

@@ -1,4 +1,6 @@
# Note: this file is from https://github.com/AbdBarho/stable-diffusion-webui-docker/blob/master/build/Dockerfile
# Note: this file is modified from https://github.com/AbdBarho/stable-diffusion-webui-docker/blob/master/build/Dockerfile
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*adapted from

@@ -0,0 +1,24 @@
# To launch a 1 GPU instance to run stable diffusion web tool.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: SkyPilot YAML run stable diffusion web tool on 1 V100 GPU.

- "donkey playing poker"
- "UC Berkeley student writing code on a laptop"
- "Marvel vs. DC"
- "toilet human"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's remove this one :)

Copy link
Collaborator

@romilbhardwaj romilbhardwaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! The example works well - we can iterate on the README as required later.

@concretevitamin concretevitamin merged commit 3f8f6d4 into skypilot-org:master Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants