|
| 1 | +--- |
| 2 | +title: "How do I get started using the Demos feature?" |
| 3 | +type: docs |
| 4 | +tags: |
| 5 | +- Demos |
| 6 | +--- |
| 7 | + |
| 8 | +The Demos feature allows you to easily share your |
| 9 | +[Gradio](https://gradio.app/) machine learning app (demo) both publicly and |
| 10 | +privately. |
| 11 | + |
| 12 | +To get started using the Demos feature, you need to: |
| 13 | + |
| 14 | +1. [Add a demo to your Lambda GPU Cloud account]({{< relref "#add-a-demo-to-your-lambda-gpu-cloud-account" >}}). |
| 15 | +1. [Host your demo on a new instance]({{< relref "#host-your-demo-on-a-new-instance" >}}). |
| 16 | + |
| 17 | +{{% alert title="Note" color="info" %}} |
| 18 | +It currently isn't possible to host a demo on an existing instance. |
| 19 | +{{% /alert %}} |
| 20 | + |
| 21 | +{{% alert title="Note" color="info" %}} |
| 22 | +The new instance hosting your demo can be used like any other Lambda GPU Cloud |
| 23 | +on-demand instance. For example, you can SSH into the instance and |
| 24 | +[open Jupyter Notebook]({{< relref "open-jupyter-notebook" >}}) on the |
| 25 | +instance. |
| 26 | + |
| 27 | +As with other Lambda GPU Cloud on-demand instances, |
| 28 | +[you're billed for all of the time the instance for your demo is running]({{< relref "on-demand-instance-invoicing" >}}). |
| 29 | +{{% /alert %}} |
| 30 | + |
| 31 | +{{% alert title="Note" color="info" %}} |
| 32 | +The Demos feature can be hosted on multi-GPU instance types. However, Demos |
| 33 | +uses only one of the GPUs. |
| 34 | + |
| 35 | +<!-- TODO: Remove the below sentence when it's no longer true. --> |
| 36 | +Also, demos currently can't be hosted on H100 instances. |
| 37 | +{{% /alert %}} |
| 38 | + |
| 39 | +## Add a demo to your Lambda GPU Cloud account |
| 40 | + |
| 41 | +1. In the left sidebar of the |
| 42 | + [dashboard](https://cloud.lambdalabs.com/instances), click **Demos**. Then, |
| 43 | + click the **Add demo** button at the top-right of the dashboard. |
| 44 | + |
| 45 | + The **Add a demo** dialog will appear. |
| 46 | + |
| 47 | + {{< imgproc add-a-demo Resize "400x" >}}{{< /imgproc >}} |
| 48 | + |
| 49 | +1. Under **Demo Source URL**, enter the URL of the Git repository containing |
| 50 | + your demo's source code. |
| 51 | + |
| 52 | + {{% alert title="Note" color="info" %}} |
| 53 | + The Demos feature looks in your Git repository for a file named |
| 54 | + `README.md`. If the file doesn't exist, or if the file doesn't contain the |
| 55 | + required properties, you'll receive a **Demo misconfigured** error. |
| 56 | + |
| 57 | + {{< imgproc demo-misconfigured Resize "300x" >}}{{< /imgproc >}} |
| 58 | + |
| 59 | + The `README.md` _must_ have at the top a YAML block containing the |
| 60 | + following: |
| 61 | + |
| 62 | + ```yaml |
| 63 | + --- |
| 64 | + sdk: gradio |
| 65 | + sdk_version: GRADIO-VERSION |
| 66 | + app_file: PATH-TO-APP-FILE |
| 67 | + --- |
| 68 | + ``` |
| 69 | + |
| 70 | + Replace **GRADIO-VERSION** with the version of Gradio your demo is built |
| 71 | + with, for example, `3.24.1`. |
| 72 | + |
| 73 | + Replace **PATH-TO-APP-FILE** with the path to your Gradio application file |
| 74 | + (the file containing the Gradio |
| 75 | + [interface code](https://gradio.app/docs/#interface)), |
| 76 | + relative to the root of your Git repository. For example, if your Gradio |
| 77 | + application file is named `app.py` and is located in the root directory of |
| 78 | + your Git repository, replace **PATH-TO-APP-FILE** with `app.py`. |
| 79 | + |
| 80 | + Properties other than `sdk`, `sdk_version`, and `app_file` are ignored by |
| 81 | + the Demos feature. |
| 82 | + {{% /alert %}} |
| 83 | + |
| 84 | + {{% alert title="Tip" color="success" %}} |
| 85 | + If you don't yet have your own demo, you can try the Demos feature using |
| 86 | + the |
| 87 | + [demos created by Lambda's Machine Learning team](https://huggingface.co/lambdalabs). |
| 88 | + Demos created by Lambda's Machine Learning team include: |
| 89 | + |
| 90 | + - [Stable Diffusion Image Variations](https://huggingface.co/spaces/lambdalabs/stable-diffusion-image-variations) |
| 91 | + - [Image Mixer](https://huggingface.co/spaces/lambdalabs/image-mixer-demo) |
| 92 | + - [Avatar text to image](https://huggingface.co/spaces/lambdalabs/text-to-avatar) |
| 93 | + {{% /alert %}} |
| 94 | + |
| 95 | +1. Under **Visibility**, choose: |
| 96 | + |
| 97 | + - **Public** if you want to list your demo in the |
| 98 | + [library of public models shared by the Lambda community](https://cloud.lambdalabs.com/demos). |
| 99 | + - **Unlisted** if you want your demo accessible only by those who know your |
| 100 | + demo's URL. |
| 101 | + |
| 102 | +1. Under **Name**, give your demo a name. If you choose to make your demo |
| 103 | + public, the name of your demo will appear in the Lambda library of public |
| 104 | + models. The name of your demo will also appear in your demo's URL. |
| 105 | + |
| 106 | +1. (Optional) Under **Description**, enter a description for your demo. |
| 107 | + |
| 108 | + The description shows under the name of your demo in your library of demos. |
| 109 | + If your demo is public, the description also shows under the name of your |
| 110 | + demo in the Lambda library of public models. |
| 111 | + |
| 112 | + {{% alert title="Note" color="info" %}} |
| 113 | + You can't change the name or description of your demo once you add it. |
| 114 | + However, you can delete your demo then add it again. |
| 115 | + {{% /alert %}} |
| 116 | + |
| 117 | +1. Click **Add demo** to save your demo to your Lambda GPU Cloud account. |
| 118 | + |
| 119 | +## Host your demo on a new instance |
| 120 | + |
| 121 | +1. In the [Demos dashboard](https://cloud.lambdalabs.com/edit-demos), find the |
| 122 | + row containing the demo you want to host, then click **Host**. Follow the |
| 123 | + prompts to launch a new instance. |
| 124 | + |
| 125 | + [Your new instance will take several minutes to launch]({{< relref "how-long-instance-launch" >}}) |
| 126 | + and for your demo to become accessible. |
| 127 | + |
| 128 | + {{% alert title="Note" color="info" %}} |
| 129 | + The link to your demo might temporarily appear in the Instances dashboard, |
| 130 | + then disappear. This is expected behavior and doesn't mean your instance or |
| 131 | + demo is broken. |
| 132 | + |
| 133 | + The models used by demos are often several gigabytes in size, and can take 5 |
| 134 | + to 15 minutes to download and load. |
| 135 | + {{% /alert %}} |
| 136 | + |
| 137 | +1. Once your instance is launched and your demo is accessible, a link with |
| 138 | + your demo's name will appear under the **Demo** column. Click the link to |
| 139 | + access your demo. |
| 140 | + |
| 141 | + {{% alert title="Tip" color="success" %}} |
| 142 | + To see a gallery of all of your demos, at the top-right of the Demos |
| 143 | + dashboard, click the **See your demos** button. |
| 144 | + |
| 145 | + {{< imgproc see-your-demos Resize "300x" >}}{{< /imgproc >}} |
| 146 | + {{% /alert %}} |
| 147 | + |
| 148 | +## Troubleshooting demos |
| 149 | + |
| 150 | +If you experience trouble accessing your demo, the Demos logs can be helpful |
| 151 | +for troubleshooting. |
| 152 | + |
| 153 | +To view the Demos log files, SSH into your instance or open a terminal in |
| 154 | +[Jupyter Notebook]({{< relref "open-jupyter-notebook" >}}), then run: |
| 155 | + |
| 156 | +```bash |
| 157 | +sudo bash -c 'for f in /root/virt-sysprep-firstboot.log ~demo/bootstrap.log; do printf "### BEGIN $f\n\n"; cat $f; printf "\n### END $f\n\n"; done > demos_debug_logs.txt; printf "### BEGIN journalctl -u lambda-demos.service\n\n$(journalctl -u lambda-demos.service)\n\n### END journalctl -u lambda-demos.service" >> demos_debug_logs.txt' |
| 158 | +``` |
| 159 | + |
| 160 | +This command will produce a file named `demos_debug_logs.txt` containing the |
| 161 | +logs for the Demos feature. You can review the logs from within your instance |
| 162 | +by running `less demos_debug_logs.txt`. Alternatively, you can download the |
| 163 | +file locally to review or share. |
| 164 | + |
| 165 | +{{% alert title="Note" color="info" %}} |
| 166 | +The [Lambda Support](https://lambdalabs.com/support) team provides only basic |
| 167 | +support for the Demos feature. However, assistance might be available in the |
| 168 | +[community forum](https://deeptalk.lambdalabs.com/). |
| 169 | + |
| 170 | +If you're experiencing problems using the Demos feature, running the above |
| 171 | +command and |
| 172 | +[providing the `demos_debug_logs.txt` file to the Support team](https://support.lambdalabs.com/hc/en-us/requests/new) |
| 173 | +can help with future improvements to the Demos feature. |
| 174 | +{{% /alert %}} |
| 175 | + |
| 176 | +Here are some examples of how problems present in logs: |
| 177 | + |
| 178 | +### Misconfigured README.md file |
| 179 | + |
| 180 | +``` |
| 181 | +### BEGIN /home/demo/bootstrap.log |
| 182 | +
|
| 183 | +Cloning into '/home/demo/source'... |
| 184 | +Traceback (most recent call last): |
| 185 | + File "<stdin>", line 17, in <module> |
| 186 | + File "<stdin>", line 15, in load |
| 187 | + File "pydantic/main.py", line 526, in pydantic.main.BaseModel.parse_obj |
| 188 | + File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__ |
| 189 | +pydantic.error_wrappers.ValidationError: 3 validation errors for Metadata |
| 190 | +sdk |
| 191 | + field required (type=value_error.missing) |
| 192 | +sdk_version |
| 193 | + field required (type=value_error.missing) |
| 194 | +app_file |
| 195 | + field required (type=value_error.missing) |
| 196 | +Created symlink /etc/systemd/system/multi-user.target.wants/lambda-demos-error-server.service → /etc/systemd/system/lambda-demos-error-server.service. |
| 197 | +Bootstrap failed: misconfigured |
| 198 | +
|
| 199 | +### END /home/demo/bootstrap.log |
| 200 | +``` |
| 201 | + |
| 202 | +### Not a Gradio app |
| 203 | + |
| 204 | +``` |
| 205 | +### BEGIN /home/demo/bootstrap.log |
| 206 | +
|
| 207 | +Cloning into '/home/demo/source'... |
| 208 | +Traceback (most recent call last): |
| 209 | + File "<stdin>", line 17, in <module> |
| 210 | + File "<stdin>", line 15, in load |
| 211 | + File "pydantic/main.py", line 526, in pydantic.main.BaseModel.parse_obj |
| 212 | + File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__ |
| 213 | +pydantic.error_wrappers.ValidationError: 2 validation errors for Metadata |
| 214 | +sdk |
| 215 | + unexpected value; permitted: 'gradio' (type=value_error.const; given=docker; permitted=('gradio',)) |
| 216 | +sdk_version |
| 217 | + field required (type=value_error.missing) |
| 218 | +Created symlink /etc/systemd/system/multi-user.target.wants/lambda-demos-error-server.service → /etc/systemd/system/lambda-demos-error-server.service. |
| 219 | +Bootstrap failed: misconfigured |
| 220 | +
|
| 221 | +### END /home/demo/bootstrap.log |
| 222 | +``` |
0 commit comments