diff --git a/docs.json b/docs.json index 66d396b6..aae80d98 100644 --- a/docs.json +++ b/docs.json @@ -235,6 +235,7 @@ { "group": "Pods", "pages": [ + "tutorials/pods/comfyui-flux", "tutorials/pods/run-your-first", "tutorials/pods/run-fooocus", "tutorials/pods/run-ollama", diff --git a/tutorials/pods/comfyui-flux.mdx b/tutorials/pods/comfyui-flux.mdx new file mode 100644 index 00000000..edd801c3 --- /dev/null +++ b/tutorials/pods/comfyui-flux.mdx @@ -0,0 +1,197 @@ +--- +title: "Generate images with ComfyUI and Flux" +sidebarTitle: "Generate images with ComfyUI" +description: "Deploy ComfyUI on Runpod to create AI-generated images." +tag: "NEW" +--- + +This tutorial walks through how to configure ComfyUI on a [GPU Pod](/pods/overview), and use it to generate images using text-to-image models. + +[ComfyUI](https://www.comfy.org/) is a node-based graphical interface for creating AI image generation workflows. Instead of writing code, you connect different components visually to build custom image generation pipelines. This approach provides flexibility to experiment with various models and techniques while maintaining an intuitive interface. + +[Flux](https://huggingface.co/black-forest-labs/FLUX.1-dev) is a state-of-the-art text-to-image AI model developed by Black Forest Labs. It generates high-quality images from text descriptions and comes in three versions: + +- **Flux Schnell**: An open-source model optimized for speed and cost. +- **Flux Dev**: An open-source model optimized for visual fidelity and prompt adherence. +- **Flux Pro**: A premium version available through API access. + +The template used in this tutorial uses the Flux Dev model, but you can learn how to install other models (including non-Flux models) in the [Workflow customization](#install-missing-models) section. + +## What you'll learn + +In this tutorial you'll learn how to: + +- Deploy a Pod with ComfyUI pre-installed. +- Connect to the ComfyUI web interface. +- Generate your first AI image. +- Browse pre-configured workflow templates. +- Download new models and workflow nodes to your Pod. + +## Requirements + +Before you begin, you'll need: + +- A [Runpod account](/get-started/manage-accounts). +- At least $10 in credits. +- Basic understanding of AI image generation. + +## Step 1: Deploy a ComfyUI Pod + +First we'll deploy a Pod using a template that pre-installs ComfyUI and and the ComfyUI Manager plugin: + + + + Navigate to the [Better Comfy Slim](https://console.runpod.io/explore/cndsag8ob0) template in the Runpod console and click **Deploy**. + + + + Configure your Pod with these settings: + + - **GPU selection:** Choose an L40 or RTX 4090 for optimal performance with Flux models. Lower VRAM GPUs may work for smaller models. + - **Storage:** The default container and disk volume sizes set by the template should be sufficient for Flux Dev. You can also add a [network volume](/pods/storage/create-network-volumes) to your Pod if you want persistent storage. + - **Deployment type:** Select **On-Demand** for flexibility. + + + + Click **Deploy On-Demand** to create your Pod. + + The Pod will take up to 30 minutes to initialize the container, download the Flux Dev model, and start the ComfyUI service. + + + +## Step 2: Open the ComfyUI interface + +Once your Pod is finished initializing you can open the ComfyUI interface: + + + + Navigate to the [Pods section](https://www.runpod.io/console/pods) in the Runpod console, then find your deployed ComfyUI Pod and expand it. + + + The Pod will take up to 30 minutes to initialize when first deployed, but if you stop and restart the Pod it generally takes much less time to reinitialize. + + + + + Click **Connect** on your Pod, then select **Connect to HTTP Service [Port 7860]**. + + This will open the ComfyUI interface in a new browser tab. The URL follows the format: `https://[POD_ID]-7860.proxy.runpod.net`. + + + If you see an error when first connecting, wait 2-3 minutes for the HTTP service to fully start, then refresh the page. + + + + + + + + +## Step 3: Import an example Flux workflow + + The Pod template we deployed comes with the Flux Dev model pre-installed, but you'll need a valid workflow to use it. Follow these steps to import a pre-configured Flux workflow: + + + + Visit the [flux-runpod repository](https://github.com/camenduru/flux-runpod/tree/main), locate the `Flux.1-Dev-ComfyUI.json` file, and click the download button in the top right corner of the code block. + + + + In the ComfyUI interface: + 1. Click **Workflow** in the top right corner. + 2. Select **Open**. + 3. Select the `Flux.1-Dev-ComfyUI.json` file using the file browser to upload it. + + + +## Step 4: Generate your first image + +Now the workflow is loaded, follow these steps to generate an image: + + + + Locate the text input node labeled "CLIP Text Encode (Prompt)" in the workflow. + + Click on the text field containing the default prompt and replace it with your desired image description. + + Example prompts: + - "A serene mountain landscape at sunset with a crystal clear lake" + - "A futuristic cityscape with neon lights and flying vehicles" + - "A detailed portrait of a robot reading a book in a library" + + + + Click **Run** at the bottom of the workflow (or press Ctrl+Enter) to begin the image generation process. + + Watch as the workflow progresses through each node: + - Text encoding. + - Model loading. + - Image generation steps. + - Final output processing. + + + + The generated image appears in the output node when complete. + + Right-click the image to save it to your local machine, view it at full resolution, or copy it to your clipboard. + + + +Congratulations! You've just generated your first image with ComfyUI on Runpod. + +## Workflow customization + +Once you're comfortable with basic image generation, explore the [ComfyUI documentation](https://docs.comfy.org/) to learn how to build more advanced workflows. + +Here are ideas for where to start: + +### Browse workflow templates + +In the top-right corner of the ComfyUI interface, click **Workflow** and select **Browse Templates**. This will open a modal with a list of pre-configured workflows. + +You can also browse the web for a preconfigured workflow and import it using the procedure from [Step 3](#step-3-import-a-flux-workflow). + +### Install missing models + +When you open a workflow, you may see a pop-up labeled **Missing Models**, indicating that the workflow requires additional models not present in your Pod. Clicking the **Download** button in the pop-up will download the model to your local machine rather than your running Pod. You can then use the [Runpod CLI](/runpodctl/overview) to [transfer the model files](/runpodctl/transfer-files) to your Pod. + +You can also download the model directly to your Pod using the ComfyUI Manager plugin (which comes pre-installed in the ComfyUI Pod template we used). To install a model using the plugin: + +1. Click **Manager** in the top right of the ComfyUI interface. +2. Select **Model Manager**. +3. Search for the model(s) you need. +4. Click **Install**. + +### Create custom workflows + +Build your own workflows by: + +1. Right-clicking the canvas to add new nodes. +2. Connecting node outputs to inputs by dragging between connection points. +3. Saving your custom workflow clicking **Workflow** and selecting **Save**. + +## Manage your Pod + +While working with ComfyUI, monitor your usage by checking GPU utilization and generation times in the [Pods page](https://console.runpod.io/pods) of the Runpod console. + +Stop your Pod when you're finished to avoid unnecessary charges. + +It's also a good practice to download any custom workflows to your local machine before stopping the Pod. For persistent storage of models and outputs across sessions, consider using a [network volume](/pods/storage/create-network-volumes). + +## Troubleshooting + +Here are some common issues and solutions: + +- **Connection errors**: Wait for the Pod to fully initialize (up to 30 minutes for initial deployment). +- **HTTP service not ready**: Wait at least 2-3 minutes after Pod deployment for the HTTP service to fully start. +- **Out of memory errors**: Reduce image resolution or batch size in your workflow. +- **Slow generation**: Ensure you're using an appropriate GPU for your selected model. + +## Next steps + +Now that you've mastered the basics of running ComfyUI on Runpod: + +- Explore [other AI templates](/pods/templates/overview) available on Runpod. +- Learn about [persistent storage options](/pods/storage/types) for saving your work. +- Connect to your Pod [via SSH](/pods/configuration/use-ssh) for advanced customization. +- Join the [Runpod Discord](https://discord.gg/runpod) to share your creations and get support. \ No newline at end of file