KJNodes/memorygenerated

End Recording CUDAMemory History(EndRecordCUDAMemoryHistory)

This node technically invokes PyTorch's torch。

End Record CUDA Memory History

input
output_path
input
COMBO
output_path
comfy_cuda_memory_history
KJNodes

The End Recording CUDAMemory History node is used to stop recording and save a CUDA memory history snapshot. It is typically paired with a node that starts the recording, capturing GPU memory allocation and deallocation events that occur between them, and saves the data to a file. This node is designed to help users analyze and visualize GPU memory usage within deep learning workflows.

Node Functionality

Technically, this node generates a memory snapshot file by calling PyTorch's torch.cuda.memory._dump_snapshot() function. It first clears the cache and then generates a timestamped .pt file. This file format is compatible with PyTorch's official memory visualization tools and can be used for subsequent in-depth analysis.

Node Parameter Description - End Recording CUDAMemory History

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
inputCOMBOYes--Passes the received input data through unchanged, maintaining workflow connectivity.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
output_pathSTRINGYescomfy_cuda_memory_history-The output path for the final generated complete memory snapshot file.

Output

Parameter NameData TypeDescription
inputANYPasses the received input data through unchanged, maintaining workflow connectivity.
output_pathSTRINGThe output path for the final generated complete memory snapshot file.

Usage Scenarios

When debugging complex workflows or large models, you can place this node after a sequence of nodes that may consume significant GPU memory. For example, connecting this node at the end of a workflow containing multiple high-definition image generation and upscaling steps can capture memory fluctuations throughout the entire generation process, helping to identify memory leaks or optimize batch sizes.

Notes

It is important to note that frequently recording memory snapshots may have a slight impact on performance, so it is recommended to use this node only when debugging is necessary. The generated snapshot file contains the memory state at a specific point in time and requires specialized tools (such as PyTorch Memory Viz) or accompanying visualization nodes for interpretation.

The End Recording CUDAMemory History node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…