@@ -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