Skip to main content

ComfyUV Deployment Guide

Overview

This guide explains how to deploy the Docker image:

sandichhuu/comfyuv on Docker Hub

The image provides a pre-configured environment for running ComfyUI with:

  • Python managed by UV
  • Optimized PyTorch environment
  • SageAttention support
  • CUDA acceleration
  • Containerized deployment workflow

What is ComfyUI?

ComfyUI Official Documentation

ComfyUI is an open-source node-based interface and inference engine for generative AI. It allows users to build highly customizable workflows for:

  • Image generation
  • Video generation
  • Audio generation
  • Model chaining
  • Advanced AI pipelines

Unlike traditional GUI-based Stable Diffusion applications, ComfyUI exposes the entire generation graph as nodes, giving users:

  • Full workflow control
  • Better reproducibility
  • Easier automation
  • Advanced optimization possibilities
  • Lower VRAM usage in many workflows

ComfyUI is widely used in:

  • AI art pipelines
  • Video generation workflows
  • VFX production
  • Research environments
  • Automation systems

(ComfyUI Documentation)


Why Run ComfyUI in Docker?

Running ComfyUI inside Docker provides several advantages:

Isolation

Dependencies stay inside the container and do not pollute the host OS.

Reproducibility

Every deployment uses the same environment, package versions, CUDA stack, and optimizations.

Easier GPU Stack Management

CUDA + PyTorch + Triton + custom attention kernels are notoriously fragile. Docker prevents dependency drift.

Safer Custom Nodes

ComfyUI custom nodes execute Python code. Containerization helps isolate potentially unsafe packages.

Community discussions around Dockerized ComfyUI deployments frequently mention easier maintenance and safer experimentation workflows. (Reddit)


Why This Image Uses UV

UV Package Manager

This image uses UV instead of traditional pip + venv.

UV is a modern Python package manager written in Rust and designed for extremely fast dependency resolution and installation.

Benefits of UV

Faster Dependency Resolution

UV resolves Python dependency graphs significantly faster than pip.

Faster Virtual Environment Creation

Environment creation is near-instant compared to traditional Python tooling.

Better Layer Caching in Docker

UV improves Docker build efficiency because dependency resolution and wheel caching behave more predictably.

Deterministic Builds

Using lockfiles and strict dependency resolution reduces "works on my machine" problems.

Lower Cold Start Time

When rebuilding containers or deploying across multiple systems, UV reduces setup overhead dramatically.


Why UV is Faster for PVC / Persistent Volume Workloads

In containerized AI environments, PVCs (Persistent Volume Claims) or mounted volumes are commonly used for:

  • Python caches
  • Model storage
  • Wheels
  • HuggingFace cache
  • ComfyUI custom nodes
  • Virtual environments

Traditional pip workflows perform many small filesystem operations:

  • Metadata checks
  • Repeated dependency scans
  • Wheel extraction overhead
  • Redundant IO

UV is faster because it:

  • Uses aggressive caching
  • Minimizes Python interpreter overhead
  • Performs dependency resolution in Rust
  • Reduces filesystem thrashing
  • Optimizes parallel operations

This becomes especially noticeable on:

  • Kubernetes PVCs
  • NFS mounts
  • SMB shares
  • NAS-backed Docker volumes
  • Slow SSDs
  • Remote storage

In practice, this means:

  • Faster container rebuilds
  • Faster startup times
  • Faster node installation
  • Faster CI/CD pipelines

This matters heavily for ComfyUI because AI environments often contain very large dependency trees and multiple CUDA-related wheels.


SageAttention vs FlashAttention

What is FlashAttention?

FlashAttention is a highly optimized attention algorithm for transformers that reduces memory usage and improves throughput.

FlashAttention improves:

  • VRAM efficiency
  • Throughput
  • Attention kernel performance

Especially for:

  • Stable Diffusion
  • LLMs
  • Video generation
  • Large batch inference

What is SageAttention?

SageAttention is a newer optimized attention backend focused on:

  • Lower latency
  • Better throughput
  • Improved inference efficiency
  • Better compatibility with newer GPUs

Why SageAttention Can Be Better

Lower VRAM Usage

SageAttention can reduce VRAM pressure in some inference workloads.

This is especially valuable for:

  • Flux models
  • Video workflows
  • Large resolution generations
  • Multi-model pipelines

Better Throughput on New GPUs

Modern GPUs like:

  • RTX 4090
  • RTX 5090
  • Ada Lovelace
  • Hopper architectures

often benefit more from SageAttention kernels.

Community reports frequently mention noticeable speedups in ComfyUI video workflows. (Reddit)


Improved Stability

FlashAttention builds are sometimes fragile because they depend heavily on:

  • CUDA version
  • PyTorch version
  • Triton version
  • Compiler toolchains

SageAttention can be easier to maintain in modern container environments.


Better for Video Pipelines

Video generation workloads repeatedly execute attention operations across many frames.

SageAttention can significantly improve:

  • Frame throughput
  • Render speed
  • Memory efficiency

which is important for:

  • WAN
  • Flux video
  • AnimateDiff
  • Hunyuan video workflows

Requirements

Before deploying:

Required

  • NVIDIA GPU
  • NVIDIA Container Toolkit
  • Docker Engine
  • CUDA-compatible drivers
  • 16GB+ VRAM
  • SSD storage
  • Linux host

Quick Start

Pull the Image

docker pull sandichhuu/comfyuv:latest

Run the Container

docker run -it --rm \
  --gpus all \
  -p 8188:8188 \
  -v ./models:/comfyui/models \
  -v ./output:/comfyui/output \
  sandichhuu/comfyuv:latest

Docker Compose Example

services:
  comfyuv:
    image: sandichhuu/comfyuv:cu132cpp313
    container_name: comfyuv
    ipc: host
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]
    volumes:
      - ./config.ini:/comfy/user/__manager/config.ini
      - ./input:/comfy/input
      - ./output:/comfy/output
      - ./workflows:/comfy/user/default/workflows
      - ./models:/comfy/models
      - comfy:/comfy
      - comfyuv_python_packages:/usr/local/lib/python3.13/site-packages
    environment:
      - DO_NOT_TRACK=1
      - COMFY_NO_TELEMETRY=1
    command: >
      --listen 0.0.0.0
      --enable-triton-backend
      --enable-manager
      --use-sage-attention
      --disable-pinned-memory
      --fast fp8_matrix_mult autotune
      --front-end-version Comfy-Org/ComfyUI_frontend@latest

volumes:
  comfyuv:
  comfyuv_python_packages:

Start:

docker compose up -d

Access ComfyUI

Open:

http://localhost:8188

Recommended Volume Layout

project/
├── models/
├── input/
├── output/
├── custom_nodes/
└── docker-compose.yml

Recommended NVIDIA Runtime Check

Verify GPU access:

docker run --rm --gpus all nvidia/cuda:12.8.0-base-ubuntu22.04 nvidia-smi

Recommended Production Setup

For long-term deployments:

  • Reverse proxy with Caddy or Traefik
  • HTTPS enabled
  • Authentication layer
  • Dedicated model storage volume
  • Watchtower auto-updates (optional)

Notes

  • First startup may take time due to model indexing.
  • Large models should be mounted from persistent storage.
  • SageAttention support depends on GPU architecture and CUDA compatibility.
  • Some custom nodes may still require additional dependencies.

Useful Links

(docs.docker.com)