|
| 1 | +# Using model weights in Tigris anywhere with Skypilot |
| 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 | +[Skypilot](https://skypilot.readthedocs.io/en/latest/docs/index.html) is a tool |
| 11 | +that lets you route GPU compute to the cheapest possible locale based on your |
| 12 | +requirements. The same configuration lets you control AWS, Azure, Google Cloud, |
| 13 | +Oracle Cloud, Kubernetes, Runpod, Fluidstack, or more. For more information |
| 14 | +about Skypilot, check out |
| 15 | +[their documentation](https://skypilot.readthedocs.io/en/latest/docs/index.html). |
| 16 | + |
| 17 | +To get started, you'll need to install Skypilot |
| 18 | +[following their directions](https://skypilot.readthedocs.io/en/latest/getting-started/installation.html). |
| 19 | +Be sure to have [Conda](https://anaconda.org/anaconda/conda) installed. |
| 20 | + |
| 21 | +You will need to configure your cloud of choice for this example. See |
| 22 | +[Skypilot's documentation](https://skypilot.readthedocs.io/en/latest/getting-started/installation.html#cloud-account-setup) |
| 23 | +on how to do this. We have tested this against a few clouds: |
| 24 | + |
| 25 | +- [AWS](https://aws.amazon.com/) |
| 26 | +- [Lambda](https://lambdalabs.com/) |
| 27 | +- [Runpod](https://www.runpod.io/) |
| 28 | + |
| 29 | +However the other providers should work fine. |
| 30 | + |
| 31 | +## Customizing the `skypilot.yaml` file |
| 32 | + |
| 33 | +Open `skypilot.yaml` in your favorite text editor. Customize the environment |
| 34 | +variables in the `envs:` key: |
| 35 | + |
| 36 | +```yaml |
| 37 | +envs: |
| 38 | + # Tigris config |
| 39 | + AWS_ACCESS_KEY_ID: tid_AzureDiamond # workload access key ID |
| 40 | + AWS_SECRET_ACCESS_KEY: tsec_hunter2 # workload secret access key |
| 41 | + AWS_ENDPOINT_URL_S3: https://fly.storage.tigris.dev |
| 42 | + AWS_REGION: auto |
| 43 | + |
| 44 | + # Bucket names |
| 45 | + MODEL_BUCKET_NAME: model-storage |
| 46 | + PUBLIC_BUCKET_NAME: generated-images |
| 47 | + |
| 48 | + # Model to load |
| 49 | + MODEL_PATH: ByteDance/SDXL-Lightning |
| 50 | +``` |
| 51 | +
|
| 52 | +| Envvar name | Value | |
| 53 | +| ----------------------: | :----------------------------------------------------- | |
| 54 | +| `AWS_ACCESS_KEY_ID` | The access key ID from the workload keypair | |
| 55 | +| `AWS_SECRET_ACCESS_KEY` | The secret access key from the workload keypair | |
| 56 | +| `AWS_ENDPOINT_URL_S3` | `https://fly.storage.tigris.dev` | |
| 57 | +| `AWS_REGION` | `auto` | |
| 58 | +| `MODEL_PATH` | `ByteDance/SDXL-Lightning` | |
| 59 | +| `MODEL_BUCKET_NAME` | `model-storage` (replace with your own bucket name) | |
| 60 | +| `PUBLIC_BUCKET_NAME` | `generated-images` (replace with your own bucket name) | |
| 61 | + |
| 62 | +## Launching it in a cloud |
| 63 | + |
| 64 | +Run `sky serve up` to start the image in a cloud: |
| 65 | + |
| 66 | +```text |
| 67 | +sky serve up skypilot.yaml -n sdxl |
| 68 | +``` |
| 69 | + |
| 70 | +Wait a few minutes for everything to converge, and then you can use the endpoint |
| 71 | +URL to poke it: |
| 72 | + |
| 73 | +```text |
| 74 | +⚙︎ Service registered. |
| 75 | +
|
| 76 | +Service name: sdxl |
| 77 | +Endpoint URL: 3.84.60.169:30001 |
| 78 | +``` |
| 79 | + |
| 80 | +:::note |
| 81 | + |
| 82 | +You can run `sky serve status` to find out if your endpoint is ready: |
| 83 | + |
| 84 | +```text |
| 85 | +$ sky serve status |
| 86 | +<...> |
| 87 | +Service Replicas |
| 88 | +SERVICE_NAME ID VERSION ENDPOINT LAUNCHED RESOURCES STATUS REGION |
| 89 | +sdxl 1 1 http://69.30.85.69:22112 47 secs ago 1x RunPod({'RTXA4000': 1}) READY CA |
| 90 | +``` |
| 91 | + |
| 92 | +::: |
| 93 | + |
| 94 | +Finally, run a test generation with this curl command: |
| 95 | + |
| 96 | +```text |
| 97 | +curl "http://ip:port/predictions/$(uuidgen)" \ |
| 98 | + -X PUT \ |
| 99 | + -H "Content-Type: application/json" \ |
| 100 | + --data-binary '{ |
| 101 | + "input": { |
| 102 | + "prompt": "The space needle in Seattle, best quality, masterpiece", |
| 103 | + "aspect_ratio": "1:1", |
| 104 | + "guidance_scale": 3.5, |
| 105 | + "num_inference_steps": 4, |
| 106 | + "max_sequence_length": 512, |
| 107 | + "output_format": "png", |
| 108 | + "num_outputs": 1 |
| 109 | + } |
| 110 | +}' |
| 111 | +``` |
| 112 | + |
| 113 | +If all goes well, you should get an image like this: |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | +You can destroy the machine with this command: |
| 118 | + |
| 119 | +```text |
| 120 | +sky serve down sdxl |
| 121 | +``` |
0 commit comments