H3 Free Cache (empty allocator between stages):
H3FreeCache is a specialized node designed to optimize the management of VRAM (Video Random Access Memory) in AI art generation workflows. Its primary function is to act as a passthrough that returns the allocator's cached-but-free VRAM to the driver before the next stage of processing. This is particularly useful in scenarios where VRAM usage can spike unexpectedly, such as during the VAE (Variational Autoencoder) decode phase after a long H3 pass. By freeing up VRAM that is no longer in use, H3FreeCache helps prevent memory bloat and ensures that the system can efficiently allocate resources for subsequent tasks. This process incurs a minimal time cost of a few milliseconds and does not alter any mathematical computations, making it a seamless addition to your workflow. The node is strategically placed to sit right before the VAE Decode stage, ensuring that VRAM is optimally managed without interrupting the flow of data.
H3 Free Cache (empty allocator between stages) Input Parameters:
samples
This parameter represents the latent data that is passed through the node. It is essential for maintaining the continuity of data flow in the AI art generation process. The samples parameter does not have specific minimum or maximum values as it is dependent on the data being processed. It serves as the primary input that the node processes and returns unchanged, ensuring that the VRAM management operations do not interfere with the data itself.
also_gc
The also_gc parameter is a boolean option that determines whether Python's garbage collection should be invoked before freeing the VRAM cache. When set to True, it triggers gc.collect(), which helps release any dead Python references and their associated tensors, further optimizing memory usage. The default value is True, and it is recommended to keep this setting enabled to maximize the efficiency of VRAM management. This parameter provides an additional layer of memory optimization by ensuring that all possible resources are freed before proceeding to the next stage.
H3 Free Cache (empty allocator between stages) Output Parameters:
samples
The samples output parameter is the same latent data that was input into the node. It is returned unchanged, ensuring that the data integrity is maintained throughout the VRAM management process. This output is crucial for continuing the workflow without any disruption, as it allows subsequent nodes to receive the necessary data for further processing.
report
The report output parameter provides a textual summary of the VRAM management operation performed by the node. It details the amount of VRAM reserved before and after the cache was emptied, as well as the amount of live memory allocated. This report is valuable for monitoring and debugging purposes, as it gives insights into the effectiveness of the VRAM management and helps identify any potential memory issues.
H3 Free Cache (empty allocator between stages) Usage Tips:
- Place the H3FreeCache node right before the VAE Decode stage to ensure optimal VRAM management and prevent memory bloat during this critical phase.
- Keep the
also_gcparameter set toTrueto maximize memory efficiency by releasing dead Python references and their associated tensors. - Use the
reportoutput to monitor VRAM usage and identify any potential memory issues that may arise during the workflow.
H3 Free Cache (empty allocator between stages) Common Errors and Solutions:
"CUDA out of memory"
- Explanation: This error occurs when the GPU runs out of available VRAM to allocate for new operations.
- Solution: Ensure that the H3FreeCache node is correctly placed before memory-intensive stages like VAE Decode. Consider reducing the batch size or model complexity to lower VRAM demands.
"gc.collect() not releasing memory"
- Explanation: Sometimes, Python's garbage collector may not release memory as expected, leading to higher VRAM usage.
- Solution: Verify that the
also_gcparameter is set toTrue. If the issue persists, manually inspect the code for any lingering references that may prevent garbage collection.
"Unexpected increase in VRAM usage"
- Explanation: This may happen if the VRAM cache is not being emptied as intended.
- Solution: Check the
reportoutput to ensure that the cache is being cleared. If not, review the node's placement and ensure it is correctly configured to execute before the VAE Decode stage.
