KJNodes/memorygenerated

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

image_pass
model_pass
any_output
image_pass
model_pass
freemem_before
freemem_after
empty_cache
gc_collect
unload_all_models
any_input
COMBO
KJNodes

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 NameData TypeRequiredDefault ValueRange/OptionsDescription
any_inputIONo--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_passIMAGENo--image_pass (Output Parameter): Returns the image data from the image_pass input unchanged.
model_passMODELNo--model_pass (Output Parameter): Returns the model data from the model_pass input unchanged.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
empty_cacheBOOLEANYesTrue-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_collectBOOLEANYesTrue-gc_collect (Input Parameter): A boolean switch that determines whether to force a garbage collection cycle. Enabled by default.
unload_all_modelsBOOLEANYesFalse-unload_all_models (Input Parameter): A boolean switch that determines whether to unload all models from ComfyUI's memory. Disabled by default.

Output

Parameter NameData TypeDescription
any_outputANYany_output (Output Parameter): Returns the data from the any_input input unchanged.
image_passIMAGEimage_pass (Output Parameter): Returns the image data from the image_pass input unchanged.
model_passMODELmodel_pass (Output Parameter): Returns the model data from the model_pass input unchanged.
freemem_beforeINTfreemem_before (Output Parameter): The amount of free system VRAM in bytes before any cleanup operations are performed.
freemem_afterINTfreemem_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.

The VRAM Debug node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…