Skip to content

Commit 8013529

Browse files
committed
docs/blueprints/model-storage: use SDXL instead of Flux
I tried. I really tried. I'm not skilled enough in fighting the diffusers library to make Flux use less than 49 GB of vram. I tried everything that was documented to work and found out it was all broken in any number of ways that made me feel like I was being gaslit hard. It's not as flashy to use SDXL here, but I needed to get _something_ working, so I fell back to what I know will work. Signed-off-by: Xe Iaso <[email protected]>
1 parent a2cd79f commit 8013529

File tree

3 files changed

+66
-28
lines changed

3 files changed

+66
-28
lines changed

docs/blueprints/model-storage/fly-io.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,35 @@ in:
2424
fly apps create your-app-name-here
2525
```
2626

27-
Then create a GPU machine with an a100-80gb GPU in it:
27+
As a reminder, this example is configured with environment variables. Set the
28+
following environment variables in your deployments:
29+
30+
| Envvar name | Value |
31+
| ----------------------: | :----------------------------------------------------- |
32+
| `AWS_ACCESS_KEY_ID` | The access key ID from the runner keypair |
33+
| `AWS_SECRET_ACCESS_KEY` | The secret access key from the runner keypair |
34+
| `AWS_ENDPOINT_URL_S3` | `https://fly.storage.tigris.dev` |
35+
| `AWS_REGION` | `auto` |
36+
| `MODEL_PATH` | `ByteDance/SDXL-Lightning` |
37+
| `MODEL_BUCKET_NAME` | `model-storage` (replace with your own bucket name) |
38+
| `PUBLIC_BUCKET_NAME` | `generated-images` (replace with your own bucket name) |
39+
40+
Then create a GPU machine with an l40s GPU in it in Seattle:
2841

2942
```text
3043
fly machine run \
3144
-a your-app-name-here \
32-
--name fluxschnell \
45+
--name sdxl-lightning \
3346
-e AWS_ACCESS_KEY_ID=<runner-keypair-access-key-id> \
3447
-e AWS_SECRET_ACCESS_KEY=<runner-keypair-secret-access-key> \
3548
-e AWS_ENDPOINT_URL_S3=https://fly.storage.tigris.dev \
3649
-e AWS_REGION=auto \
3750
-e MODEL_BUCKET_NAME=model-storage \
3851
-e PUBLIC_BUCKET_NAME=generated-images \
39-
-e MODEL_PATH=black-forest-labs/FLUX.1-schnell \
40-
--vm-gpu-kind a100-80gb \
41-
-r sjc \
42-
your-docker-username/flux-tigris:latest \
52+
-e MODEL_PATH=ByteDance/SDXL-Lightning \
53+
--vm-gpu-kind l40s \
54+
-r sea \
55+
your-docker-username/sdxl-tigris:latest \
4356
-- python -m cog.server.http --host ::
4457
```
4558

@@ -73,10 +86,10 @@ curl "http://localhost:5001/predictions/$(uuidgen)" \
7386
-H "Content-Type: application/json" \
7487
--data-binary '{
7588
"input": {
76-
"prompt": "The word 'success' in front of the Space Needle, anime depiction, best quality",
77-
"aspect_ratio": "16:9",
89+
"prompt": "The space needle in Seattle, best quality, masterpiece",
90+
"aspect_ratio": "1:1",
7891
"guidance_scale": 3.5,
79-
"num_inference_steps": 50,
92+
"num_inference_steps": 4,
8093
"max_sequence_length": 512,
8194
"output_format": "png",
8295
"num_outputs": 1
@@ -91,5 +104,5 @@ If all goes well, you should get an image like this:
91104
You can destroy the machine with this command:
92105

93106
```text
94-
fly machine destroy --force -a your-app-name-here fluxschnell
107+
fly machine destroy --force -a your-app-name-here sdxl-lightning
95108
```

docs/blueprints/model-storage/index.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ enabling your workloads to start quickly no matter where they are in the world.
2424
## Getting Started
2525

2626
For this example, we’ll set up
27-
[Flux.1 [schnell]](https://huggingface.co/black-forest-labs/FLUX.1-schnell) by
28-
Black Forest Labs for inference with the weights stored in Tigris.
27+
[SDXL Lightning](https://huggingface.co/ByteDance/SDXL-Lightning) by ByteDance
28+
for inference with the weights stored in Tigris.
2929

3030
Create two new buckets:
3131

32-
1. One bucket will be for generated flux images, it’ll be called
33-
`generated-images` in this article
32+
1. One bucket will be for generated images, it’ll be called `generated-images`
33+
in this article
3434
2. One bucket will be for storing models, it’ll be called `model-storage` in
3535
this article
3636

3737
Both of these buckets should be private.
3838

39-
Download the flux-in-tigris template from GitHub:
39+
Download the `sdxl-in-tigris` template from GitHub:
4040

4141
```text
42-
git clone https://github.com/tigrisdata-community/flux-in-tigris
42+
git clone https://github.com/tigrisdata-community/sdxl-in-tigris
4343
```
4444

4545
Enter the folder in a terminal window.
@@ -73,7 +73,7 @@ pip install -r requirements.txt
7373
Then run the script to upload a model:
7474

7575
```text
76-
python scripts/prepare_model.py black-forest-labs/FLUX.1-schnell model-storage
76+
python scripts/prepare_model.py ByteDance/SDXL-Lightning model-storage
7777
```
7878

7979
This will take a bit to run, depending on your internet connection speed, hard
@@ -99,20 +99,32 @@ variables:
9999
AWS_ENDPOINT_URL_S3=https://fly.storage.tigris.dev
100100
AWS_REGION=auto
101101
MODEL_BUCKET_NAME=model-storage
102-
MODEL_PATH=black-forest-labs/FLUX.1-schnell
102+
MODEL_PATH=ByteDance/SDXL-Lightning
103103
```
104104

105+
:::info
106+
107+
Want differently styled images? Try finetunes like
108+
[Kohaku XL](https://huggingface.co/KBlueLeaf/Kohaku-XL-Zeta)! Pass the Hugging
109+
Face repo name to the `prepare_model` script like this:
110+
111+
```text
112+
python scripts/prepare_model.py KBlueLeaf/Kohaku-XL-Zeta model-storage
113+
```
114+
115+
:::
116+
105117
## Deploying it
106118

107119
In order to deploy this, you need to build the image with the cog tool. Log into
108120
a Docker registry and run this command to build and push it:
109121

110122
```text
111-
cog push your-docker-username/flux-tigris --use-cuda-base-image false
123+
cog push your-docker-username/sdxl-tigris --use-cuda-base-image false
112124
```
113125

114126
You can now use it with your GPU host of choice as long as it supports Cuda 12.1
115-
and has at least 80 GB of video memory.
127+
and has at least 12 GB of video memory.
116128

117129
This example is configured with environment variables. Set the following
118130
environment variables in your deployments:
@@ -123,7 +135,7 @@ environment variables in your deployments:
123135
| `AWS_SECRET_ACCESS_KEY` | The secret access key from the runner keypair |
124136
| `AWS_ENDPOINT_URL_S3` | `https://fly.storage.tigris.dev` |
125137
| `AWS_REGION` | `auto` |
126-
| `MODEL_PATH` | `black-forest-labs/FLUX.1-schnell` |
138+
| `MODEL_PATH` | `ByteDance/SDXL-Lightning` |
127139
| `MODEL_BUCKET_NAME` | `model-storage` (replace with your own bucket name) |
128140
| `PUBLIC_BUCKET_NAME` | `generated-images` (replace with your own bucket name) |
129141

docs/blueprints/model-storage/vast-ai.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ pip install --upgrade vastai;
2727
Follow Vast.ai's instructions on
2828
[how to load your API key](https://cloud.vast.ai/cli/).
2929

30-
Then you need to find an instance. This example requires a GPU with 80 GB of
30+
Then you need to find an instance. This example requires a GPU with 12 GB of
3131
vram. Use this command to find a suitable host:
3232

3333
```text
34-
vastai search offers 'verified=true cuda_max_good>=12.1 gpu_ram>=80 num_gpus=1 inet_down>=850' -o 'dph+'
34+
vastai search offers 'verified=true cuda_max_good>=12.1 gpu_ram>=12 num_gpus=1 inet_down>=850' -o 'dph+'
3535
```
3636

3737
The first column is the instance ID for the launch command. You can use this to
@@ -42,11 +42,24 @@ assemble your launch command. It will be made up out of the following:
4242
- A signal to the runtime that we need 48 GB of disk space to run this app
4343
- The onstart command telling the runtime to start the cog process
4444

45+
As a reminder, this example is configured with environment variables. Set the
46+
following environment variables in your deployments:
47+
48+
| Envvar name | Value |
49+
| ----------------------: | :----------------------------------------------------- |
50+
| `AWS_ACCESS_KEY_ID` | The access key ID from the runner keypair |
51+
| `AWS_SECRET_ACCESS_KEY` | The secret access key from the runner keypair |
52+
| `AWS_ENDPOINT_URL_S3` | `https://fly.storage.tigris.dev` |
53+
| `AWS_REGION` | `auto` |
54+
| `MODEL_PATH` | `ByteDance/SDXL-Lightning` |
55+
| `MODEL_BUCKET_NAME` | `model-storage` (replace with your own bucket name) |
56+
| `PUBLIC_BUCKET_NAME` | `generated-images` (replace with your own bucket name) |
57+
4558
Format all of your environment variables as you would in a `docker run` command.
4659
EG:
4760

4861
```text
49-
"-p 5000:5000 -e AWS_ACCESS_KEY_ID=<runner-keypair-access-key-id> -e AWS_SECRET_ACCESS_KEY=<runner-keypair-secret-access-key> -e AWS_ENDPOINT_URL_S3=https://fly.storage.tigris.dev -e AWS_REGION=auto -e MODEL_BUCKET_NAME=model-storage -e MODEL_PATH=black-forest-labs/FLUX.1-schnell -e PUBLIC_BUCKET_NAME=generated-images"
62+
"-p 5000:5000 -e AWS_ACCESS_KEY_ID=<runner-keypair-access-key-id> -e AWS_SECRET_ACCESS_KEY=<runner-keypair-secret-access-key> -e AWS_ENDPOINT_URL_S3=https://fly.storage.tigris.dev -e AWS_REGION=auto -e MODEL_BUCKET_NAME=model-storage -e MODEL_PATH=ByteDance/SDXL-Lightning -e PUBLIC_BUCKET_NAME=generated-images"
5063
```
5164

5265
Then execute the launch command:
@@ -55,7 +68,7 @@ Then execute the launch command:
5568
vastai create instance \
5669
<id-from-search> \
5770
--image your-docker-username/flux-tigris:latest \
58-
--env "-p 5000:5000 -e AWS_ACCESS_KEY_ID=<runner-keypair-access-key-id> -e AWS_SECRET_ACCESS_KEY=<runner-keypair-secret-access-key> -e AWS_ENDPOINT_URL_S3=https://fly.storage.tigris.dev -e AWS_REGION=auto -e MODEL_BUCKET_NAME=model-storage -e MODEL_PATH=black-forest-labs/FLUX.1-schnell -e PUBLIC_BUCKET_NAME=generated-images" \
71+
--env "-p 5000:5000 -e AWS_ACCESS_KEY_ID=<runner-keypair-access-key-id> -e AWS_SECRET_ACCESS_KEY=<runner-keypair-secret-access-key> -e AWS_ENDPOINT_URL_S3=https://fly.storage.tigris.dev -e AWS_REGION=auto -e MODEL_BUCKET_NAME=model-storage -e MODEL_PATH=ByteDance/SDXL-Lightning -e PUBLIC_BUCKET_NAME=generated-images" \
5972
--disk 48 \
6073
--onstart-cmd "python -m cog.server.http"
6174
```
@@ -95,10 +108,10 @@ curl "http://ip:port/predictions/$(uuidgen)" \
95108
-H "Content-Type: application/json" \
96109
--data-binary '{
97110
"input": {
98-
"prompt": "The word 'success' in front of the Space Needle, anime depiction, best quality",
99-
"aspect_ratio": "16:9",
111+
"prompt": "The space needle in Seattle, best quality, masterpiece",
112+
"aspect_ratio": "1:1",
100113
"guidance_scale": 3.5,
101-
"num_inference_steps": 50,
114+
"num_inference_steps": 4,
102115
"max_sequence_length": 512,
103116
"output_format": "png",
104117
"num_outputs": 1

0 commit comments

Comments
 (0)