Skip to content

ComfyUI on Windows: Out-of-Memory Errors and Startup Flags That Actually Exist

Scope: ComfyUI on Windows (native Python environment or the Windows Portable build) where image generation reports insufficient VRAM or a tensor-allocation failure, or a workflow runs inconsistently - it works after closing a browser or game but fails at higher resolution or with more nodes. The article is organized as "identify the error - check the flags your version really has - inspect usage - adjust the memory strategy - verify", with copyable commands at each step.

Short answer: ComfyUI's VRAM problems cannot be debugged by copying Ollama's playbook. ComfyUI is a PyTorch-based image generation workflow tool; Ollama is a language model runtime using its own scheduler plus the llama.cpp/GGML backend. Their error wording, flag names, and memory management are all different. The ComfyUI official repository and the startup flags reference are the sources the commands and flag names here were checked against, with the cli_args.py source as the definitive definition. Change is rapid: many widely circulated flags are no longer in the source, so wherever a flag's existence is involved this article says "verify with python main.py --help" instead of treating an old tutorial as current fact.

1. First, identify which layer is complaining

The first step is not to add a flag but to confirm who is actually saying "out of memory". ComfyUI loads models and samples through PyTorch's CUDA allocator, so the common failure carries the hallmarks of a PyTorch tensor-allocation error, often with the number of bytes requested; workflow front ends or custom nodes may also produce their own resource messages. Mixing the two sends you down the wrong path: an allocator failure calls for checking the VRAM budget and environment versions, while a node-level hint calls for checking workflow configuration. Error text changes with PyTorch, ComfyUI, and driver versions - verify against your environment.

Draw a firm line against Ollama here. Ollama's typical signs are 100% CPU or a mixed ratio in the PROCESSOR column of ollama ps, or an offloaded-layers line in its log. None of that applies to ComfyUI: it has no ollama ps command and no num_ctx context parameter. Conversely, ComfyUI startup flags should not be used to fix Ollama. If both stacks run on one machine, separate the VRAM each occupies before deciding which to touch. For the LLM-side memory framing, see Ollama Deployment Handbook on this site, but borrow only the mental model, not the commands.

2. Check which flags your version really supports

This is the step most easily derailed by old tutorials. At the time of writing, the current ComfyUI source comfy/cli_args.py and the official startup-flags page list the following memory-related flags, all defined in one mutually exclusive group:

--gpu-only   store and run everything (text encoders, CLIP, etc.) on the GPU
--highvram   keep models in GPU memory instead of unloading to CPU after use
--lowvram    no effect when dynamic VRAM is enabled; otherwise runs text encoders on CPU
--novram     when --lowvram is not enough
--cpu        use the CPU for everything (slow)
--reserve-vram <GB>  VRAM reserved for the OS and other software
--vram-headroom <GB>  extra dynamic-VRAM headroom, default 0
--disable-dynamic-vram / --enable-dynamic-vram  turn dynamic VRAM off / on

Two points deserve emphasis. First, dynamic VRAM and async weight offloading are on by default on Nvidia and AMD GPUs in the current version, so --lowvram often does nothing in the default state - quite different from old tutorials saying "always add --lowvram for low VRAM". Second, this article did not find --medvram in the current source or the flags page, while the current README troubleshooting section even advises removing all command-line flags, saying most flags people claim improve performance do the opposite. Whether --medvram exists in your build must therefore be tested with python main.py --help; it is marked as needing site confirmation here rather than given a fixed answer. The same applies to every default value above: the on-site output wins.

3. Inspect usage: who is holding the VRAM

Look at the scene before changing flags. In Windows, open PowerShell or a terminal and run:

nvidia-smi

Watch two things: total versus used VRAM, and the process list below it for browser hardware acceleration, games, or other AI tools holding memory. This is a general NVIDIA operations technique rather than a step ComfyUI's own docs prescribe for this tool, so it is also marked as needing site confirmation; it still decides the direction: if another process owns the VRAM, clearing it beats any flag; if ComfyUI itself is the main consumer, move on to the next section. Task Manager's GPU tab cross-checks the same conclusion, so you are not relying on a single tool's reading.

Also note that a Portable build and a Python environment may coexist, so more than one ComfyUI can be installed. Confirm which copy you actually launch and which GPU it uses before reading its VRAM. When practical, run nvidia-smi at three points - baseline, after model load, and during sampling - to see a curve instead of a single snapshot.

4. Adjust the memory strategy using the official wording

Once ComfyUI itself is confirmed to be filling VRAM, try the following in order, rerunning the same workflow after each change.

Update the environment before touching flags. The current README says Nvidia cards require pytorch cu130 or higher, with torch 2.7 as the minimum supported version, and recommends updating an outdated PyTorch. On an old environment no flag can compensate for an underlying library mismatch; this step outranks every switch below. Exact requirements depend on your installed distribution's notes.

Give the system headroom with reserve and headroom. --reserve-vram sets VRAM reserved for the operating system and other software, while --vram-headroom keeps extra free space above the default dynamic-VRAM headroom; the docs say ComfyUI keeps this much VRAM completely free and unused, even counting memory used by other apps. When desktop composition, a browser, or the driver needs a little VRAM, these two are more precise than switching to a low-VRAM mode. Start from a small value - exact numbers vary.

Only then consider mode switches. If the above is insufficient, try --novram and then --cpu, remembering that --cpu runs everything on the CPU and slows down steeply, useful only as a "get it running first" fallback. If several models must stay resident, --highvram does the opposite - it keeps models in VRAM after use - so do not use it by mistake. --gpu-only also increases pressure by putting text encoders on the GPU. These switches are mutually exclusive; enable one at a time. For the broader trade-off framework see Inference Engine Selection on this site, but note it discusses LLM serving stacks - borrow only the "choose by budget" framing.

5. Windows Portable specifics

Windows Portable users do not type flags at a command prompt; they add them to .bat launch files. The official flags page gives run_nvidia_gpu.bat as an example and shows a command-line combination such as python main.py --listen 0.0.0.0 --port 8288 --disable-auto-launch --lowvram. Back up the original .bat before editing, launch from that file, and check that the flags printed in the console match what you wrote - this rules out "edited one file but launched another". The current README describes Windows Portable as a self-contained build you can unzip and run, suitable when you do not want to configure a Python environment. File names and layout vary by distribution - verify against your environment.

If the workflow uses quantized models, one line in the current README troubleshooting section matters: it advises removing GGUF-related nodes and models in favor of ComfyUI-native formats, saying the native formats are much faster. This differs from the LLM-side rule that lower quantization saves more VRAM, because the two loading paths differ. The LLM-side method of estimating weight size by quantization tier is in LLM Quantization in Practice on this site - again as a mental model only, not as guidance for choosing ComfyUI nodes.

6. Acceptance checklist before calling it done

  • Identified whether the error came from the PyTorch allocator or a workflow/node layer, without mixing ComfyUI and Ollama terminology
  • Verified with python main.py --help which flags exist; did not assume historical flags such as --medvram are current
  • Confirmed the PyTorch and CUDA environment meets the current README's version requirements
  • Checked VRAM at baseline and while running with nvidia-smi, and ruled out other processes grabbing it
  • Enabled only one mode switch at a time and reran the same workflow after each change
  • Confirmed the state of dynamic VRAM and async offloading, and know when --lowvram is a no-op
  • Edited the .bat that actually launches, and the console prints the expected flags
  • Recorded the ComfyUI version, PyTorch version, driver version, and the nvidia-smi output at the time, for later comparison

One last principle: an out-of-memory error is not a single fault but a combination of budget and environment. Determine whether someone else grabbed the VRAM, the environment is outdated, or the workflow genuinely exceeds the card's physical limit, then treat that cause. Walk the manual path once before baking flags into a launch script - otherwise the script has no interpretation baseline. This site's Enterprise Model Serving Notes discusses resource isolation for multi-user scenarios; the ideas are useful, but that setting is different from local image generation.