A production-ready Docker setup for ComfyUI that unlocks the full potential of NVIDIA Blackwell GPUs (RTX 50 series) through 4-bit quantization with NVFP4.
This Docker setup gives you:
- π 3x faster image generation vs standard 16-bit models
- πΎ 3.5x less VRAM usage - Run FLUX.2 Klein on 16GB GPUs
- π Sandboxed environment - ComfyUI runs in a container, your system stays clean
- πͺ Blackwell optimization - Native NVFP4 support for RTX 50 series GPUs
- π¦ Persistent data - Models, outputs, and custom nodes stay on your host machine
- π¨ Full ComfyUI features - Custom nodes, workflows, everything works
NVIDIA's Blackwell architecture introduces NVFP4, a 4-bit floating-point format that maintains image quality while dramatically reducing memory usage and increasing speed. This isn't your typical "lossy compression" - it's a hardware-accelerated precision format designed specifically for AI workloads.
Real-world results:
- FLUX.1-dev: ~12 seconds on RTX 5090 (vs 40+ seconds in BF16)
- Memory: 6.77GB model size (vs 24GB in BF16)
- Quality: Virtually identical to full precision
- NVIDIA GPU: Blackwell architecture (RTX 50 series) recommended
- RTX 5090, 5080, 5070, etc.
- Also works on Ampere (RTX 30xx) and Ada (RTX 40xx) but without NVFP4 acceleration
- VRAM: 16GB minimum, 24GB+ recommended
- Storage: 100GB+ free (AI models are large and so is the image for comfyui)
- RAM: 16GB minimum
- Docker: Version 20.10 or newer (Install Docker)
- Docker Compose: Version 2.0 or newer (usually included with Docker)
- NVIDIA Container Toolkit: Required for GPU support (Install Guide)
- NVIDIA Driver: 560.x or newer for Blackwell support, you really want the latest for the best compatibility and performance.
git clone https://github.com/ChiefNakor/comfyui-blackwell-docker.git
cd comfyui-blackwell-dockermkdir -p models output input custom_nodes usercp .env.example .env
# Edit .env with your preferred settings (optional - defaults work fine)docker-compose buildThis takes 10-15 minutes on first build, maybe longer. Grab a coffee β
docker-compose up -dOpen your browser and go to:
http://localhost:8188
After setup, your folder should look like this:
comfyui-blackwell-docker/
βββ docker-compose.yml # Container configuration
βββ Dockerfile # Image build instructions
βββ .env # Your custom settings (create from .env.example)
βββ .env.example # Template configuration with docs
βββ wheels.txt # Python packages (Nunchaku wheel)
βββ models/ # AI models (checkpoints, VAEs, etc.)
βββ output/ # Generated images go here
βββ input/ # Place input images here
βββ custom_nodes/ # ComfyUI custom nodes
βββ user/ # Workflows and settings
This is where Docker differs from a normal ComfyUI installation:
-
Install via ComfyUI Manager (as usual)
- Open ComfyUI in your browser
- Use ComfyUI Manager to install nodes
- The node code downloads to
./custom_nodes/
-
Rebuild the Docker image (this is the critical part!)
docker-compose down docker-compose build docker-compose up -d
Custom nodes often have Python dependencies listed in requirements.txt. The Docker build process:
- Finds these
requirements.txtfiles - Installs dependencies in the image
- Protects your PyTorch version from conflicts
- Ensures everything starts cleanly
If you don't rebuild, the node might appear installed but fail at runtime when it can't find its dependencies.
You can install several nodes, then rebuild once:
# Install node 1, node 2, node 3 via Manager
docker-compose down
docker-compose build # Installs all new requirements
docker-compose up -dTo get the performance benefits, you need 4-bit quantized models:
-
FLUX Models - Nunchaku FLUX on HuggingFace
- Download quantized FLUX.1-dev (6.77GB vs 24GB)
- Place in
models/diffusion_models/ - black-forest-labs have official nvfp4 models too, look around!
-
Other Models - Check Nunchaku documentation
Regular (BF16/FP16) models still work fine - you just won't get the NVFP4 speed boost. The setup works with all ComfyUI models.
For the life of me I couldn't get nvfp4 text models working with CLIP loader- the way nvfp4 stuffs up the shape of the model hasn't been resolved yet in comfyui. You may have to just use a fp8/fp16 model for this at this stage - may change in the future. Your mileage may vary.
The .env file controls everything. There is a detailed explanation of whats going on in the env.example file, you will need to create your own .env file and set it up accordingly.
Key settings:
MODELS_PATH=./models # Where AI models live
OUTPUT_PATH=./output # Where images are saved
CUSTOM_NODES_PATH=./custom_nodesRESERVE_VRAM=1.5 # Leave 1.5GB for system (adjust per your GPU)
COMFYUI_ARGS=--lowvram --async-offload # Memory optimization flagsFor 24GB+ cards, you can remove --lowvram for a speed boost:
COMFYUI_ARGS=--async-offload- When PyTorch updates, you will need to go wheel hunting and edit these:
TORCH_WHEEL_URL
TORCHAUDIO_WHEEL_URL
TORCHVISION_WHEEL_URL
- When CUDA updates, you will need to edit:
CUDA_BASE_IMAGE
This is explained in more detail in env.example
Edit wheels.txt with the new wheel URL from: https://github.com/nunchaku-ai/nunchaku/releases
Nunchaku is in wheels.txt so it will be part of the build, comment this out if you don't want it.
NOTE: You may need to change the config.ini setting security_level = weak to get nunchaku to install, it relaxes the rule so the installer works.
If you have other python packages you specifically want to install, you can by specifying their wheel in wheels.txt. This is explained in further detail in the wheels.txt file.
Then rebuild:
docker-compose build --no-cacheSageAttention is installed from source - because the pypi wheel is from 2024 (old)... So your choices are either v2, v3 or none. Select this as a variable in .env.
From the SageAttention github repo:
Currently, SageAttention3 works well for:
- Video generation models: CogVideoX-2B, HunyuanVideo, Mochi.
- Almost all image generation models, including Flux and Stable-Diffusion3.5.
Note: SageAttention3 does not guarantee lossless acceleration for all models. For other video generation models, we recommend selectively using SageAttention2++ in certain layers or timesteps.
So you can chop and change, you just have to change the .env and then rebuild the docker image with:
docker-compose build --no-cacheImportant directories to backup:
custom_nodes/- Your installed nodesuser/- Your workflows and settingsmodels/- Your downloaded models (large!)
Models can be re-downloaded, but workflows and custom node configs are unique to you.
MIT License - See LICENSE file for details
Built with β€οΈ by Chief Nakor for the AI art community