Skip to main content
This example demonstrates how to deploy a Gradio web application that generates images using Stable Diffusion, running on a Ray cluster managed by Ray Serve. The application allows users to input text prompts and receive generated images in response, leveraging GPU resources for efficient inference.

Prerequisites

  • Kubernetes cluster with GPUs (L40 or above recommended)
  • GPU Operators installed and configured (e.g., NVIDIA device plugin)
  • KubeRay operator installed and configured
  • kubectl configured to access the cluster
  • Hugging Face access token with read permissions for stabilityai/stable-diffusion-3-medium-diffusers

Step 1: Create the Hugging Face token secret

Step 2: Deploy

This creates:
  • ConfigMap (stable-diffusion-gradio-code): contains the Stable Diffusion Gradio app code
  • RayService (stable-diffusion-gradio): Ray cluster with a head node and GPU worker(s), running the app via Ray Serve

Step 3: Check status

Wait for the RayService to become ready:
Check pod status:

Step 4: Access the Gradio UI

The service is exposed via NodePort on port 31770:
To find the node port, if needed:
To find the cluster ID: “Screenshot Placeholder” Alternatively, port-forward to access locally:
Then open http://localhost:8000.

Cleanup