ComfyUI Setup

testing MIT ComfyUIDockerBashPythonCUDA

Repository

This page was translated automatically from Italian. Read the original

ComfyUI Setup: video, images and audio with artificial intelligence on your GPU

Create video, images and audio with artificial intelligence on your computer, using free models. No subscriptions, no credits to buy, no files uploaded to someone else’s servers: your graphics card does the work, and what you create stays in your home.

ComfyUI is the most powerful tool available today to do this, but it is also one of the most difficult to set up. This project is a script that does the hard work for you: it checks your system, measures your GPU, builds a ComfyUI installation with over a hundred pre-configured extensions, launches it with the right settings for your hardware and, when requested, downloads the models and workflows to get you started.


What you can create

WhatWith which models
VideoClips from text or a photo, long videos via segments, intermediate frames for smoothness, upscaleWan 2.2 (14B and 5B), LightX2V at 4 steps, Stable Video Infinity, RIFE, SeedVR2, LTX-2.3
ImagesRealistic photos, illustrations, text-based retouching, part replacement, enlargementsZ-Image Turbo, Juggernaut XL, Flux, Qwen-Image, FireRed Edit, ControlNet, IPAdapter
AudioSounds and effects generated by watching the video, synchronized with what is happeningMMAudio (and, outside the EU, HunyuanVideo-Foley)

And then everything the community publishes every day: the included CivitAI scraper brings the most used workflows for video, images, and audio directly into your ComfyUI, ready to open.


Why it exists

Anyone who has tried to install ComfyUI for video generation knows the struggle: finding the right PyTorch version for the card, extensions failing to load due to a library update, searching for models one by one using the exact names the workflow expects, running out of VRAM halfway through generation, and guessing parameters. Weeks of attempts before producing the first decent video.

This script is the result of those weeks, organized into a single process. Every fix it contains stems from a real error encountered on test hardware:

How it works: calibration, models, community


Tested on real hardware

Everything you find here has been tested on a normal machine, not on a server costing thousands of euros:

ComponentTest machine
Graphics cardNVIDIA GeForce RTX 4070, 12 GB VRAM
ProcessorIntel Xeon E5-2699 v4 (22 cores, 44 threads, from 2016)
Memory64 GB DDR4
Card connectionPCI Express 3.0 x16
SystemUbuntu 24.04 LTS, Docker, NVIDIA driver 595

Twelve gigabytes of VRAM are considered the minimum for 14 billion parameter video models, which alone weigh more than the card’s memory. With the settings the script applies automatically, the 4070 runs them without memory errors by swapping model parts into system RAM.

Measured times

Measured times on RTX 4070 12 GB

TaskSettingsFirst runSubsequent runsVRAM used
Image with SDXL Lightning1024×1024, 6 steps44 s4.6 s9.7 GB
Image with Z-Image Turbo1024×1024, 8 steps2 min10 s11.8 GB
Audio with MMAudio5 seconds of sound extracted from a video37 s7 s6.1 GB
Video with Wan 2.2 14B from a photo5 seconds at 832×480, LightX2V 4 steps4 min 16 s2 min 16 s10.5 GB
Video with Wan 2.2 5B from text5 seconds at 1280×704, 20 steps8 min7 min11.8 GB

The first run after startup includes loading the models from the disk (this is significantly shortened with a fast SSD); subsequent runs find them already in memory. All tests were performed with the script’s default settings, without manual tweaks, and none ran out of memory.

What came out of those tests

Red bicycle in front of a yellow wall, generated with Z-Image TurboPortrait of an old fisherman at sunset, generated with SDXL Lightning
Z-Image Turbo, 10 secondsSDXL Lightning, 4.6 seconds
The same bicycle animated with Wan 2.2: moving light and shadowsSailboat seen from above on a turquoise sea, generated from text with Wan 2.2 5B
Wan 2.2 14B: the photo above becomes a videoWan 2.2 5B: a video from a sentence

The bicycle video started exactly from the image generated with Z-Image, and MMAudio then added the sound: a small complete workflow, all running locally.


Requirements

MinimumRecommended
SystemLinux with Docker (Ubuntu or Debian)Ubuntu 22.04 or 24.04
Graphics CardNVIDIA with 8 GBNVIDIA with 12 GB or more (RTX 30, 40, 50 series)
Memory16 GB32 GB, 64 GB for long videos
Diskabout 100 GB free for the first build (then the image occupies about 50) + modelsan SSD with 250 GB free

The script automatically installs what is missing (Docker, NVIDIA drivers, NVIDIA Container Toolkit) after asking for confirmation. On Windows, you can use WSL2 with Ubuntu, but it is not a tested path.

Watch your disk space. Many gigabytes are required, and they grow with use: the Docker image occupies about 50 GB (about 100 during the first build), models range from 6 GB to over 100 GB depending on what you choose, and every execution of the CivitAI scraper can add up to 20 GB of LoRAs. Before downloading, check the space with --status and see what would be downloaded with --dry-run. If the Docker disk fills up, other containers on the machine will also suffer.


Installation

1. Download the script into an empty folder, which will become the installation folder:

mkdir ~/comfyui && cd ~/comfyui
wget https://git.eandgcode.com/egprojects/comfyuisetup/-/raw/main/setup-comfyui.sh
chmod +x setup-comfyui.sh

2. Run it:

./setup-comfyui.sh

On the first run, it creates the .env file with all settings commented out, checks the system, displays your machine’s calibration profile, and builds the Docker image. The first build takes one to two hours, depending on your connection and processor; afterwards, a startup takes a few minutes and a restart takes less than one.

3. Choose the models for what you want to do:

./setup-comfyui.sh --models video
./setup-comfyui.sh --models image,audio

4. Open your browser at http://indirizzo-del-pc:8188. In the workflow menu, you will find the quick guide and ready-to-use workflows; in the Workflow → Browse Templates menu, you can find the official ComfyUI templates, which work immediately with the downloaded models.

At the end of each execution, the script tells you what the next step is.


The models

Models are never downloaded automatically: you choose them, by category. Each set has been tested and is filtered based on your graphics card: anything that wouldn’t fit is skipped.

CommandWhat it downloadsSpace
--models videoWan 2.2 14B image-to-video and text-to-video (FP8), Wan 2.2 5B, 4-step LoRA LightX2V, encoder, VAE, RIFE interpolation, upscalerapprox. 85 GB
--models imageZ-Image Turbo with its encoder, Juggernaut XL Lightning, DMD2, 4x upscalerapprox. 29 GB
--models audioMMAudio with its components and the BigVGAN vocoderapprox. 6 GB
--models allall threeapprox. 120 GB
--full (in addition)GGUF and FP16 variants, LTX-2.3, Flux, Qwen-Image Edit, FireRed, IPAdapter, ControlNet, InstantID, SAM2, SeedVR2…up to approx. 850 GB if you take absolutely everything

Useful details:

Model Licenses

Models are free, but each has its own license. All are fine for personal use; for commercial use, check first:

ModelLicenseCommercial use
Wan 2.2, LightX2VApache 2.0yes
Z-Image Turbo, Qwen-ImageApache 2.0yes
Juggernaut XLCreativeML OpenRAIL-Myes, subject to license usage restrictions
DMD2, MMAudioCC BY-NC 4.0no
FLUX.1 devFLUX.1 [dev] Non-Commercialno (and must be accepted on Hugging Face)
LTX-2.3LTX-2 Community Licensefree under 10 million annual turnover
HunyuanVideo and HunyuanVideo-FoleyTencent Hunyuan Communitythe license is not valid in the European Union: this is why they are not in the default sets

The CivitAI scraper

CivitAI is where the ComfyUI community publishes workflows, models, and examples. The scraper searches for them for you, by category:

./setup-comfyui.sh --civitai-scraper video
./setup-comfyui.sh --civitai-scraper image,audio

For each category, it does three things:

  1. workflow: searches for the most downloaded, highest-rated, and most recent published workflows, downloads them, extracts them from archives, and places them in the ComfyUI workflow browser, in civitai/<categoria>/;
  2. examples (for images): examines the most liked images of the period and saves the ComfyUI workflow that many have embedded, so you can recreate that image and change it however you want;
  3. LoRA: downloads the most downloaded LoRAs for the models in that category, within a storage limit that you decide (20 GB by default).

Finally, it analyzes all workflows and tells you which models are missing and how many workflows need them, so you know what to download.

Keep an eye on the scraper. Workflows and examples are small, but LoRAs are not: each run can download up to SCRAPER_MAX_MODEL_GB (20 GB by default), and runs accumulate because it finds new results every time. Before launching it, check the free space with --status and the list of what it would download with --dry-run; if you only want workflows, set SCRAPER_MODELS_PER_CATEGORY=0 in the .env. Downloaded LoRAs are all stored in models/loras/civitai/, making them easy to monitor and delete.

Searches change with every execution: rerunning it will find new things. A free CivitAI token (Account settings → API Keys) is required in the .env: without it, the search works but many downloads will be rejected.

Content filter

The scraper has an active NSFW filter by default: it only requests content from CivitAI classified as safe for all audiences and discards any result with a higher rating. The --include-nsfw option disables it; results that the filter would have excluded end up in separate folders (<categoria>-nsfw). Users of this option are responsible for complying with CivitAI’s rules and their own country’s laws.


Configuration

Everything personal is contained in the .env file next to the script: if it does not exist, it is created on the first run, with a comment for each entry. No entry is mandatory for calibration. The main ones:

EntryPurpose
HF_TOKENHugging Face token, for the few models that require license acceptance
CIVITAI_TOKENCivitAI token, for the scraper
BASE_DIR, MODELS_DIRwhere to place the installation and the models (including on another disk)
COMFYUI_PORT, BIND_ADDRinterface port and which network to listen on
PERSONAL_CATALOGyour catalog of models and workflows
DOWNLOAD_PROFILE, FORCE_VRAM_GB, RAM_PROFILEto force choices different from the automatic ones
SCRAPER_*how many workflows, examples, and LoRAs the scraper searches for

An environment variable with the same name overrides the .env value. When a new version of the script introduces new entries, it adds them to the end of the .env without touching yours.

Personal Catalog

To add your own models and workflows, copy catalogo.esempio.tsv as catalogo-personale.tsv and specify it in the .env with PERSONAL_CATALOG=catalogo-personale.tsv. Each line specifies where to fetch a file (Hugging Face, CivitAI, a direct URL), where to place it, which category it belongs to, and how much memory it requires; it can also create a link with another name, for workflows that look for a file with a different name. The format is explained at the top of the example file.


All commands

CommandWhat it does
./setup-comfyui.shcalibration: prerequisites, hardware profile, build, and startup
--models <categorie>downloads models (video, image, audio, all); with --full also includes variants
--civitai-scraper <categorie>workflows, examples, and LoRAs from CivitAI
--include-nsfwdisables the NSFW filter in --models and --civitai-scraper
--dry-runshows what would be downloaded, without downloading
--downloadrepeats the last model selection and retrieves failed downloads
--jobresumes an ongoing download or scraper
--statuscontainer status, hardware profile, space, and models
--start, --stop, --restart, --logs, --shellcontainer management
--updateupdates ComfyUI and custom nodes and rebuilds the image
--rebuildrebuilds the image from scratch
--clean-modelsproposes deleting models that are too heavy for this hardware
--clean-workflows, --clean-cacheempties the workflows folder or the Hugging Face cache
--uninstallremoves container and image; data only if confirmed

What calibration does, in detail


FAQ

Can I use it on a remote PC? Yes: the script is run on the machine with the GPU and the interface can be opened from any browser on the network. ComfyUI does not have a login: if you want to access it from the Internet, place an authenticated proxy in front of it and set BIND_ADDR=127.0.0.1.

The container restarts on its own or stops halfway through a video. Check ./setup-comfyui.sh --logs. An exit code 137 means system memory is exhausted: with low RAM, set RAM_PROFILE=lowram in the .env. A cudaErrorLaunchFailure error (exit 139) halfway through generation, typical of MultiGPU/DisTorch2 nodes on 12 GB cards, can be avoided with SAFE_CUDA_MODE=1: it works, but makes everything about ten times slower, which is why it is disabled by default.

A downloaded workflow says that some models or nodes are missing. For models, check logs/workflow-analysis.txt after the scraper, or try --models <categoria> --full. For nodes, ComfyUI-Manager (in the interface menu) installs the missing ones.

How much space is actually needed? The Docker image takes up about 50 GB (during the first build, about 100 GB are required; at the end, the script offers to clear the build cache). Models depend on what you choose: from 6 GB for audio only to about 120 GB for all base sets. --status tells you how much you are using.

Can I keep the models on another disk or use the ones I already have? Yes: MODELS_DIR in the .env can point to any folder, including an existing library. Existing files are recognized and will not be re-downloaded.


License and acknowledgments

The script is distributed under the MIT license. Use it, modify it, share it.

It would not exist without ComfyUI, the authors of the custom nodes it installs, and those who publish free models and workflows on Hugging Face and CivitAI: the credit for the images and videos belongs to them; the script simply coordinates them with your graphics card. ComfyUI and the mentioned model names belong to their respective owners; this is an independent project.

If it saved you a few weeks of trial and error, you can support the project.