Model Memory Use Report Patch(ModelMemoryUseReportPatch)
The technical implementation of this node involves cloning the input model and adding two callback functions to the cloned model.
Model Memory Use Report Patch
The Model Memory Use Report Patch node. The technical implementation of this node involves cloning the input model and adding two callback functions to the cloned model.
Model Memory Use Report Patch is an experimental node designed to monitor and report the GPU memory usage of a model during the sampling process. It automatically logs and outputs peak memory consumption data by adding callback functions to the model, helping users understand the resource usage during model runtime.
Node Functionality
The technical implementation of this node involves cloning the input model and adding two callback functions to the cloned model. One function resets the CUDA memory statistics counter before sampling, and the other function calculates and logs the peak allocated memory and peak reserved memory after sampling is complete. This data is output in gigabytes via the system's logging functionality.
Node Parameter Description - Model Memory Use Report Patch
Inputs
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
model | MODEL | Yes | - | - | - |
Outputs
| Parameter Name | Data Type | Description |
|---|---|---|
| MODEL | MODEL | - |
Usage Scenarios
When debugging or optimizing complex workflows, you can insert this node after the model loading node and before the sampler node. For example, if you encounter slow generation processes or out-of-memory errors, using this node can help quickly identify which model or which sampling step consumes the most GPU memory resources.
Notes
This node relies on PyTorch's CUDA memory management interface, so it is only effective in GPU environments with CUDA enabled. It outputs a modified copy of the model and does not affect the original model.
Model Memory Use Report Patch Node Source Code Link
The Model Memory Use Report Patch node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.