Skip to content

Commit 650c637

Browse files
committed
docs/blueprints/model-storage: move each deployment target into their own pages
Signed-off-by: Xe Iaso <[email protected]>
1 parent 3536304 commit 650c637

File tree

3 files changed

+205
-186
lines changed

3 files changed

+205
-186
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Using model weights in Tigris on fly.io
2+
3+
:::note
4+
5+
The instructions on this page assume you have followed all of the steps in the
6+
main [Storing Model Weights in Tigris](/blueprints/model-storage) blueprint.
7+
8+
:::
9+
10+
Insert something about needing a fly.io account, link to the hello/tigris page
11+
for some free capitalism dollars.
12+
13+
First, create a new app for this to live in:
14+
15+
```text
16+
fly apps create your-app-name-here
17+
```
18+
19+
Then create a GPU machine with an a100-80gb GPU in it:
20+
21+
```text
22+
fly machine run \
23+
-a your-app-name-here \
24+
--name fluxschnell \
25+
-e AWS_ACCESS_KEY_ID=<runner-keypair-access-key-id> \
26+
-e AWS_SECRET_ACCESS_KEY=<runner-keypair-secret-access-key> \
27+
-e AWS_ENDPOINT_URL_S3=https://fly.storage.tigris.dev \
28+
-e AWS_REGION=auto \
29+
-e MODEL_BUCKET_NAME=model-storage \
30+
-e PUBLIC_BUCKET_NAME=generated-images \
31+
-e MODEL_PATH=black-forest-labs/FLUX.1-schnell \
32+
--vm-gpu-kind a100-80gb \
33+
-r sjc \
34+
your-docker-username/flux-tigris:latest \
35+
-- python -m cog.server.http --host ::
36+
```
37+
38+
This will print a machine IP like this:
39+
40+
```text
41+
Machine started, you can connect via the following private ip
42+
fdaa:0:641b:a7b:165:347b:d972:2
43+
```
44+
45+
Then proxy to the machine:
46+
47+
```text
48+
fly proxy -a your-app-name-here \
49+
5001:5000 \
50+
fdaa:0:641b:a7b:165:347b:d972:2
51+
```
52+
53+
Then you need to wait a few minutes while the machine sets itself up. It's done
54+
when it prints this line in the logs:
55+
56+
```text
57+
{"logger": "cog.server.probes", "timestamp": "2024-10-22T17:36:06.651457Z", "severity": "INFO", "message": "Not running in Kubernetes: disabling probe helpers."}
58+
```
59+
60+
Do a test generation with this curl command:
61+
62+
```text
63+
curl "http://localhost:5001/predictions/$(uuidgen)" \
64+
-X PUT \
65+
-H "Content-Type: application/json" \
66+
--data-binary '{
67+
"input": {
68+
"prompt": "The word 'success' in front of the Space Needle, anime depiction, best quality",
69+
"aspect_ratio": "16:9",
70+
"guidance_scale": 3.5,
71+
"num_inference_steps": 50,
72+
"max_sequence_length": 512,
73+
"output_format": "png",
74+
"num_outputs": 1
75+
}
76+
}'
77+
```
78+
79+
If all goes well, you should get an image like this:
80+
81+
![The word 'success' in front of the Space Needle](./success.webp)
82+
83+
You can destroy the machine with this command:
84+
85+
```text
86+
fly machine destroy --force -a your-app-name-here fluxschnell
87+
```

docs/blueprints/model-storage/index.md

Lines changed: 5 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -123,193 +123,12 @@ environment variables in your deployments:
123123
| `AWS_SECRET_ACCESS_KEY` | The secret access key from the runner keypair |
124124
| `AWS_ENDPOINT_URL_S3` | `https://fly.storage.tigris.dev` |
125125
| `AWS_REGION` | `auto` |
126-
| `MODEL_BUCKET_NAME` | `model-storage` (replace with your own bucket name) |
127126
| `MODEL_PATH` | `black-forest-labs/FLUX.1-schnell` |
127+
| `MODEL_BUCKET_NAME` | `model-storage` (replace with your own bucket name) |
128128
| `PUBLIC_BUCKET_NAME` | `generated-images` (replace with your own bucket name) |
129129

130-
### fly.io
131-
132-
First, create a new app for this to live in:
133-
134-
```text
135-
fly apps create your-app-name-here
136-
```
137-
138-
Then create a GPU machine with an a100-80gb GPU in it:
139-
140-
```text
141-
fly machine run \
142-
-a your-app-name-here \
143-
--name fluxschnell \
144-
-e AWS_ACCESS_KEY_ID=<runner-keypair-access-key-id> \
145-
-e AWS_SECRET_ACCESS_KEY=<runner-keypair-secret-access-key> \
146-
-e AWS_ENDPOINT_URL_S3=https://fly.storage.tigris.dev \
147-
-e AWS_REGION=auto \
148-
-e MODEL_BUCKET_NAME=model-storage \
149-
-e PUBLIC_BUCKET_NAME=generated-images \
150-
-e MODEL_PATH=black-forest-labs/FLUX.1-schnell \
151-
--vm-gpu-kind a100-80gb \
152-
-r sjc \
153-
your-docker-username/flux-tigris:latest \
154-
-- python -m cog.server.http --host ::
155-
```
156-
157-
This will print a machine IP like this:
158-
159-
```text
160-
Machine started, you can connect via the following private ip
161-
fdaa:0:641b:a7b:165:347b:d972:2
162-
```
163-
164-
Then proxy to the machine:
165-
166-
```text
167-
fly proxy -a your-app-name-here \
168-
5001:5000 \
169-
fdaa:0:641b:a7b:165:347b:d972:2
170-
```
171-
172-
Then you need to wait a few minutes while the machine sets itself up. It's done
173-
when it prints this line in the logs:
174-
175-
```text
176-
{"logger": "cog.server.probes", "timestamp": "2024-10-22T17:36:06.651457Z", "severity": "INFO", "message": "Not running in Kubernetes: disabling probe helpers."}
177-
```
178-
179-
Do a test generation with this curl command:
180-
181-
```text
182-
curl "http://localhost:5001/predictions/$(uuidgen)" \
183-
-X PUT \
184-
-H "Content-Type: application/json" \
185-
--data-binary '{
186-
"input": {
187-
"prompt": "The word 'success' in front of the Space Needle, anime depiction, best quality",
188-
"aspect_ratio": "16:9",
189-
"guidance_scale": 3.5,
190-
"num_inference_steps": 50,
191-
"max_sequence_length": 512,
192-
"output_format": "png",
193-
"num_outputs": 1
194-
}
195-
}'
196-
```
197-
198-
If all goes well, you should get an image like this:
199-
200-
![The word 'success' in front of the Space Needle](./success.webp)
201-
202-
You can destroy the machine with this command:
203-
204-
```text
205-
fly machine destroy --force -a your-app-name-here fluxschnell
206-
```
207-
208-
### Skypilot
209-
210-
TODO(Xe): all of this
211-
212-
### Vast.ai
213-
214-
Create an account on [Vast.ai](https://vast.ai) and load it with credit if you
215-
don't have one already. You should need at least $5 of credit to complete this
216-
blueprint.
217-
218-
In your virtual environment that you used to optimize your model, install the
219-
`vastai` CLI tool:
220-
221-
```text
222-
pip install --upgrade vastai;
223-
```
224-
225-
Follow Vast.ai's instructions on
226-
[how to load your API key](https://cloud.vast.ai/cli/).
130+
You can run this on any platform you want that has the right GPUs, however we
131+
have tutorials for a few platforms to try:
227132

228-
Then you need to find an instance. This example requires a GPU with 80 GB of
229-
vram. Use this command to find a suitable host:
230-
231-
```text
232-
vastai search offers 'verified=true cuda_max_good>=12.1 gpu_ram>=64 num_gpus=1 inet_down>=850' -o 'dph+'
233-
```
234-
235-
The first column is the instance ID for the launch command. You can use this to
236-
assemble your launch command. It will be made up out of the following:
237-
238-
- The docker image name you pushed to the docker hub (or another registry)
239-
- The "environment" string with your exposed ports and environment variables
240-
- A signal to the runtime that we need 48 GB of disk space to run this app
241-
- The onstart command telling the runtime to start the cog process
242-
243-
Format all of your environment variables as you would in a `docker run` command.
244-
EG:
245-
246-
```text
247-
"-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"
248-
```
249-
250-
Then execute the launch command:
251-
252-
```text
253-
vastai create instance \
254-
<id-from-search> \
255-
--image your-docker-username/flux-tigris:latest \
256-
--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" \
257-
--disk 48 \
258-
--onstart-cmd "python -m cog.server.http"
259-
```
260-
261-
It will report success with a message like this:
262-
263-
```text
264-
Started. {'success': True, 'new_contract': 13288520}
265-
```
266-
267-
The `new_contract` field is your instance ID.
268-
269-
Give it a moment to download and start up. If you want to check on it, run this
270-
command:
271-
272-
```text
273-
vastai logs <instance-id>
274-
```
275-
276-
It's done when it prints this line in the logs:
277-
278-
```text
279-
{"logger": "cog.server.probes", "timestamp": "2024-10-22T17:36:06.651457Z", "severity": "INFO", "message": "Not running in Kubernetes: disabling probe helpers."}
280-
```
281-
282-
Then fetch the IP address and port for your app with this command:
283-
284-
```text
285-
vastai show instance <instance-id> --raw | jq -r '"\(.public_ipaddr):\(.ports["5000/tcp"][0].HostPort)"'
286-
```
287-
288-
Finally, run a test generation with this curl command:
289-
290-
```text
291-
curl "http://ip:port/predictions/$(uuidgen)" \
292-
-X PUT \
293-
-H "Content-Type: application/json" \
294-
--data-binary '{
295-
"input": {
296-
"prompt": "The word 'success' in front of the Space Needle, anime depiction, best quality",
297-
"aspect_ratio": "16:9",
298-
"guidance_scale": 3.5,
299-
"num_inference_steps": 50,
300-
"max_sequence_length": 512,
301-
"output_format": "png",
302-
"num_outputs": 1
303-
}
304-
}'
305-
```
306-
307-
If all goes well, you should get an image like this:
308-
309-
![The word 'success' in front of the Space Needle](./success.webp)
310-
311-
You can destroy the machine with this command:
312-
313-
```text
314-
vastai destroy instance <instance-id>
315-
```
133+
- [Fly.io](./fly-io)
134+
- [Vast.ai](./vast-ai)

0 commit comments

Comments
 (0)