VRAM Debug(VRAM_Debug)
This node retrieves the current available GPU memory size (in bytes) by calling the `model_management` interface of ComfyUI.
VRAM Debug
The VRAM Debug node retrieves the current amount of free VRAM (in bytes) by calling ComfyUI's model_management interface.
VRAM Debug is a utility node for monitoring and managing Video RAM (VRAM). Its core function is to measure and report available VRAM capacity during workflow execution, while also providing options to clear VRAM and unload models to help users optimize resource usage.
Node Functionality
This node retrieves the current amount of free VRAM (in bytes) by calling ComfyUI's model_management interface. It supports performing three optional operations: soft cache clearing, forced garbage collection, and unloading all loaded models. These operations are designed to free up occupied VRAM resources. The node itself does not process or modify any input data; it simply passes the input data through unchanged.
Node Parameter Description - VRAM Debug
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
any_input | IO | No | - | - | any_input (Input Parameter): A generic input interface that can receive data of any type. The node does not process this data; it is used solely as one of the signals to trigger node execution. |
image_pass | IMAGE | No | - | - | image_pass (Output Parameter): Returns the image data from the image_pass input unchanged. |
model_pass | MODEL | No | - | - | model_pass (Output Parameter): Returns the model data from the model_pass input unchanged. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
empty_cache | BOOLEAN | Yes | True | - | empty_cache (Input Parameter): A boolean switch that determines whether to perform a soft cache clearing operation to attempt to free VRAM. Enabled by default. |
gc_collect | BOOLEAN | Yes | True | - | gc_collect (Input Parameter): A boolean switch that determines whether to force a garbage collection cycle. Enabled by default. |
unload_all_models | BOOLEAN | Yes | False | - | unload_all_models (Input Parameter): A boolean switch that determines whether to unload all models from ComfyUI's memory. Disabled by default. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| any_output | ANY | any_output (Output Parameter): Returns the data from the any_input input unchanged. |
| image_pass | IMAGE | image_pass (Output Parameter): Returns the image data from the image_pass input unchanged. |
| model_pass | MODEL | model_pass (Output Parameter): Returns the model data from the model_pass input unchanged. |
| freemem_before | INT | freemem_before (Output Parameter): The amount of free system VRAM in bytes before any cleanup operations are performed. |
| freemem_after | INT | freemem_after (Output Parameter): The amount of free system VRAM in bytes after the specified cleanup operations are performed. |
Usage Scenarios
In complex workflows, VRAM may gradually become exhausted after continuously generating multiple high-resolution images or switching between different large models. In such cases, this node can be inserted at key points in the workflow (e.g., between two resource-intensive nodes). By triggering its VRAM management functions, space can be freed up to ensure subsequent nodes can execute smoothly, while the output integer values allow monitoring of the cleanup effectiveness.
Notes
This node is primarily intended for debugging and resource monitoring. Its model unloading operation (when enabled) will affect other nodes in the workflow that depend on the loaded models. Therefore, it is recommended to place this node at a stage in the workflow where immediately using previously loaded models is not required, or as a cleanup step before the workflow ends.
VRAM Debug Node Source Code Link
The VRAM Debug node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.