GLM-5 is available to try on Modal. Get started
January 21, 20255 minute read

Flux.1-dev: Run a top text-to-image model on Modal

author
Yiren Lu@YirenLu
Solutions Engineer

What is Flux.1-dev?

Flux.1-dev is a powerful text-to-image model from Black Forest Labs. Together with Stable Diffusion 3.5, it is one of the best text-to-image models on the market.

Why should you run Flux.1-dev on Modal?

If you are looking to run Flux.1-dev, you will need access to a GPU in order for the inference times to be fast. There are several ways to get a GPU, but the easiest way is to use Modal.

Modal is a cloud platform designed specifically for running machine learning workloads. Unlike traditional cloud services that require complex infrastructure management, Modal provides a serverless environment where you can deploy AI models with just a few lines of Python code.

Example code for running the Flux.1-dev model on Modal

To run the following code, you will need to:

  1. Create an account at modal.com
  2. Run pip install modal to install the modal Python package
  3. Run modal setup to authenticate (if this doesn’t work, try python -m modal setup)
  4. Copy the code below into a file called app.py
  5. Run modal run app.py

Please note that this code is not optimized. For a more detailed example of how to run Flux fast with torch.compile, refer here.

Performance Considerations

The model generates images up to 1024x1024 resolution, with generation time typically ranging from 2-4 seconds on an H100 GPU. Batch processing can significantly improve throughput for bulk image generation tasks.

Additional resources

Ship your first app in minutes.

Get Started

$30 / month free compute