How to serve the FLUX.1 prompt-to-image models using Lambda Cloud on-demand instances
This tutorial shows you how to use Lambda Cloud A100 and H100 on-demand instances to download and serve a FLUX.1 prompt-to-image model. The model will be served as a Gradio app accessible with a link you can share.
You can download and serve the FLUX.1 [schnell] model without a Hugging Face account.
However, to download and serve the FLUX.1 [dev] model, you need a Hugging Face account and a User Access Token. You also need to review and accept the model license agreement.
Clone the FLUX.1 inference repository
If you haven't already, use the dashboard or Cloud API to launch a 1x or 8x A100 instance, or a 1x or 8x H100 instance. Then, SSH into the instance. Alternatively, you can use Jupyter Notebook to access the instance.
Clone the FLUX.1 inference GitHub repository to your home directory by running:
Then, change into the repository directory by running:
Install the packages needed to serve the FLUX.1 model
First, create and activate a Python virtual environment for this tutorial by running:
Then, install the packages required for this tutorial by running:
Download and serve the FLUX.1 model
To download and serve the FLUX.1 [schnell] model
Run:
To download and serve the FLUX.1 [dev] model
First, log into your Hugging Face account by running:
Replace HF-TOKEN with your Hugging Face User Account Token.
Then, run:
The FLUX.1 model is being served as a Gradio app once you see output similar to:
Access the Gradio app serving the FLUX.1 model
Open the public URL to access the Gradio app serving the FLUX.1 model.
Anyone with the public URL can access the Gradio app serving the FLUX.1 model.
As an example prompt, try:
With the FLUX.1 [dev] model, this prompt should generate an image similar to:
Last updated