Skip to content

Commit 37f5473

Browse files
sumanthgenzSumanthSumanthMichaelvll
authored
Add a faster way of launching Stable Diffusion example by pulling Docker image from GCR (skypilot-org#1216)
* add a faster way of launching stable diffusion example by pulling docker image from gcr * addressed PR comments * address more PR comments * fix more PR comments * add fixes to yaml file since model path has been updated * tailing space Co-authored-by: Sumanth <[email protected]> Co-authored-by: Sumanth <[email protected]> Co-authored-by: Zhanghao Wu <[email protected]>
1 parent 0098e35 commit 37f5473

File tree

4 files changed

+70
-11
lines changed

4 files changed

+70
-11
lines changed

examples/stable_diffusion/README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22

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

5-
2. Run: `git clone https://github.com/skypilot-org/skypilot.git && cd examples/stable_diffusion`.
5+
2. Run `git clone https://github.com/skypilot-org/skypilot.git && cd examples/stable_diffusion`
66

7-
3. Run `sky launch -c stable-diffusion stable_diffusion_docker.yaml`.
7+
3. Run `sky launch -c stable-diffusion stable_diffusion_docker.yaml`
88

9-
4. Run `ssh -L 7860:localhost:7860 stable-diffusion`.
9+
4. Run `ssh -L 7860:localhost:7860 stable-diffusion`
1010

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

1313
6. Type in text prompt and click "Generate".
1414

1515
![Stable Diffusion Web Tool UI](assets/stable_diffusion_ui.png)
1616

17-
7. Once you are done, run `sky down stable-diffusion` to terminate the VM.
17+
7. Once you are done, run `sky stop stable-diffusion` to stop the VM.
18+
19+
8. To restart VM, repeat steps 3 and 4.
1820

1921

2022
## Usage Tips
@@ -37,3 +39,4 @@
3739
- "rap song album cover"
3840
- "Wall Street bull rodeo"
3941
- "Trump in minecraft"
42+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: '3.9'
2+
3+
services:
4+
model:
5+
image: berkeleyskypilot/stable-diffusion
6+
restart: on-failure
7+
ports:
8+
- "7860:7860"
9+
volumes:
10+
- ./cache:/cache
11+
- ./output:/output
12+
- ./models:/models
13+
environment:
14+
- CLI_ARGS=--extra-models-cpu --optimized-turbo
15+
deploy:
16+
resources:
17+
reservations:
18+
devices:
19+
- driver: nvidia
20+
device_ids: ['0']
21+
capabilities: [gpu]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## GCR
2+
3+
1. Install skypilot package by following these [instructions](https://skypilot.readthedocs.io/en/latest/getting-started/installation.html).
4+
5+
2. Run `git clone https://github.com/skypilot-org/skypilot.git `.
6+
7+
3. Steps 4-6 are based on these [GCR setup instructions](https://cloud.google.com/container-registry/docs/pushing-and-pulling)
8+
9+
4. First [enable container registry](https://cloud.google.com/container-registry/docs/enable-service) in your project
10+
11+
5. Next follow these [steps](https://cloud.google.com/container-registry/docs/advanced-authentication) to install and authenticate Docker on your CLI
12+
13+
6. Ensure that you have [Storage Admin](https://cloud.google.com/storage/docs/access-control/iam-roles) permission in your project
14+
15+
7. Run `cd skypilot/examples/stable_diffusion` and `docker build Dockerfile`
16+
17+
8. Run `docker tag stable-diffusion-webui-docker_model gcr.io/(my-project)/stable-diffusion`.
18+
19+
9. Run `docker push gcr.io/(my-project)/stable-diffusion` and verify on GCR that the image is there.
20+
21+
## DockerHub
22+
23+
1. Make a free [DockerHub](https://hub.docker.com/) account.
24+
25+
2. In your CLI, run `docker login` and use the login credentials from your DockerHub account.
26+
27+
3. Run `cd skypilot/examples/stable_diffusion` and `docker build Dockerfile`
28+
29+
4. Run `docker tag stable-diffusion-webui-docker_model (my-dockerhub-username)/stable-diffusion`.
30+
31+
5. Run `docker push (my-dockerhub-username)/stable-diffusion` and verify on Dockerhub that the image is there.
32+
33+
34+

examples/stable_diffusion/stable_diffusion_docker.yaml

+8-7
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ file_mounts:
77
/stable_diffusion: .
88

99
setup: |
10-
sudo rm -r stable-diffusion-webui-docker
11-
git clone https://github.com/AbdBarho/stable-diffusion-webui-docker.git
1210
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
1311
sudo chmod +x /usr/local/bin/docker-compose
12+
cd stable-diffusion-webui-docker
13+
sudo rm -r stable-diffusion-webui-docker
14+
git clone https://github.com/AbdBarho/stable-diffusion-webui-docker.git
1415
cd stable-diffusion-webui-docker
1516
git reset --hard 0d8b7d4ac8f9ba99e041ca332547eab9d65e6360
16-
wget https://www.googleapis.com/storage/v1/b/aai-blog-files/o/sd-v1-4.ckpt?alt=media -P models
17-
mv models/'sd-v1-4.ckpt?alt=media' models/model.ckpt
18-
rm build/Dockerfile
19-
cp /stable_diffusion/Dockerfile build/
20-
docker-compose build
17+
wget https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt -P models
18+
mv models/sd-v1-4.ckpt models/model.ckpt
19+
docker pull berkeleyskypilot/stable-diffusion
20+
rm docker-compose.yml
21+
cp /stable_diffusion/docker-compose.yml .
2122
2223
run: |
2324
cd stable-diffusion-webui-docker

0 commit comments

Comments
 (0)