This example demonstrates how to deploy a Cerebrium app using an ASGI server and Gradio.
Warning: This functionality is in beta and may change in the future.
- This application uses Gradio as the frontend
- The model is hosted as a separate instance due to the differing hardware and uptime requirements between our model and the frontend. We'd like our Gradio frontend to be always-on and running on a CPU, and for our model to scale and start as necessary on GPU instances.
-
The
portshould be set to the port on which the ASGI server will run. Note that your requests to cerebrium will still be made to port 443. -
The
entrypointshould be set to the command that starts the ASGI server. -
The code lives in the
/cortexdirectory and this is also the entrypoint workdir. -
The
entrypointshould point to the ASGI server in themain.pyfile. For Uvicorn, the entrypoint should beuvicorn main:app ...[cerebrium.runtime.custom] port = 5000 entrypoint = ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5000"] healthcheck_endpoint = "/health"
- Make the necessary changes listed in the Required changes section above
- Deploy your application using
cerebrium deploy -y - In your browser, navigate to
https://api.aws.us-east-1.cerebrium.ai/v4/<your-project-id>/34-asgi-gradio-interface/to interact with the Gradio app