Skip to content

"An optimizer custom node for ComfyUI that ensures each queue execution starts in an optimal state by clearing unused VRAM and unnecessary resources between runs."

Notifications You must be signed in to change notification settings

strawberryPunch/vram_optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ StrawberryFist VRAM Optimizer for ComfyUI

Version License ComfyUI

A comprehensive VRAM management solution for ComfyUI that automatically optimizes GPU memory usage and provides real-time monitoring.

๐ŸŽฏ Features

๐Ÿ”ง VRAM Optimizer

  • Automatic VRAM cleanup after each queue execution
  • Multiple cleaning modes: Standard and Aggressive
  • Smart cleaning conditions: Clean every time or only when memory usage is high
  • Flexible timing: Clean before queue, after queue, or both
  • Manual trigger: Force cleanup with a simple parameter change
  • Real-time logging: Monitor all activities in the terminal

๐Ÿ“Š GPU Monitor

  • Real-time GPU monitoring with background thread
  • Memory usage visualization with color-coded progress bars
  • Historical data tracking with configurable history length
  • Warning system with customizable thresholds
  • Trend analysis showing memory usage patterns
  • Multiple outputs for integration with other nodes

๐Ÿš€ Installation

Method 1: ComfyUI Manager (Recommended)

  1. Open ComfyUI Manager
  2. Search for "StrawberryFist VRAM Optimizer"
  3. Click Install
  4. Restart ComfyUI

Method 2: Manual Installation

  1. Navigate to your ComfyUI custom nodes directory:
    cd ComfyUI/custom_nodes/
    
  2. Clone this repository:
    git clone https://github.com/YourUsername/comfyui-strawberryfist-vram-optimizer.git
    
  3. Restart ComfyUI

Method 3: Download ZIP

  1. Download the latest release from Releases

  2. Extract to ComfyUI/custom_nodes/

  3. Restart ComfyUI

  4. Example

image image

๐Ÿ”„ Automatic Execution Behavior The StFist - VRAM Optimizer node does not require a connection to other nodes in the workflow. Simply placing it anywhere on the canvas will trigger its execution automatically before and/or after each queue run, depending on the selected run_timing setting.

โœจ Optimization status is:

Displayed directly in the ComfyUI console output (with timestamps and memory usage details)

Also optionally passed to the status output pin for use with nodes like Show Text

This allows for non-intrusive background optimization without disrupting the workflow structure.

โœ… Tip: You can place the node in a corner of your workspace for passive VRAM management.

๐Ÿ“‹ Requirements

  • ComfyUI
  • Python 3.8+
  • PyTorch with CUDA support
  • GPUtil (automatically installed)

๐ŸŽฎ Usage

VRAM Optimizer Node

  1. Add the StFist - VRAM Optimizer node to your workflow
  2. Configure the settings:
    • enabled: Turn automatic cleaning on/off
    • clear_mode: Choose between Standard or Aggressive cleaning
    • auto_clean: Set cleaning conditions (Every Time or Only When High)
    • run_timing: Choose when to clean (After Queue, Before Queue, or Both)
    • force_run: Change this value to manually trigger cleaning

GPU Monitor Node

  1. Add the StFist - GPU Monitor node to your workflow
  2. Configure the monitoring settings:
    • monitoring_enabled: Turn real-time monitoring on/off
    • update_interval: Set monitoring frequency (0.1-10 seconds)
    • history_length: Number of data points to keep (10-300)
    • warning_threshold: Memory usage warning level (50-95%)
    • refresh_trigger: Change to force immediate update

๐Ÿ“ธ Screenshots

VRAM Optimizer in Action

๐ŸŽฎ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
๐Ÿ”ฅ StrawberryFist VRAM Optimizer v3.0 [14:23:45]
๐Ÿ”„ ์‹คํ–‰ ํšŸ์ˆ˜: 5 | ์ƒํƒœ: CLEANED_1024.3MB
โš™๏ธ ์„ค์ •: After Queue / Standard
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ“Š GPU ๋ฉ”๋ชจ๋ฆฌ ์ƒํƒœ (NVIDIA GeForce RTX 4090)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ โœ… ์‚ฌ์šฉ๋ฅ : 15.2% (GOOD)                                  โ”‚
โ”‚ ๐Ÿ“ˆ ์‚ฌ์šฉ๋Ÿ‰: 3724.1MB / 24564.0MB                         โ”‚
โ”‚ ๐ŸŸข๐ŸŸข๐ŸŸข๐ŸŸขโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœโฌœ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

GPU Monitor Dashboard

๐ŸŽฎ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
๐Ÿ”ฅ StrawberryFist GPU ์‹ค์‹œ๊ฐ„ ๋ชจ๋‹ˆํ„ฐ๋ง [14:23:45]
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ“Š GPU: NVIDIA GeForce RTX 4090
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ โš ๏ธ ์‚ฌ์šฉ๋ฅ : 75.3% (WARNING)                               โ”‚
โ”‚ ๐Ÿ“ˆ ์‚ฌ์šฉ๋Ÿ‰: 18500.2MB / 24564.0MB                        โ”‚
โ”‚ ๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸก๐ŸŸกโฌœโฌœโฌœโฌœโฌœโฌœ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ˆ ์ตœ๊ทผ ํ†ต๊ณ„ (์ตœ๊ทผ 10๊ฐœ ์ƒ˜ํ”Œ)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ ํ‰๊ท : 72.5% | ์ตœ๋Œ€: 89.1% | ์ตœ์†Œ: 65.2%                  โ”‚
โ”‚ ๊ฒฝ๊ณ  ์ž„๊ณ„๊ฐ’: 80.0%                                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“Š ํŠธ๋ Œ๋“œ: ๐Ÿ“ˆ ์ฆ๊ฐ€ ์ถ”์„ธ

โš™๏ธ Configuration

VRAM Optimizer Settings

Parameter Options Default Description
enabled On/Off On Enable/disable automatic VRAM cleaning
clear_mode Standard/Aggressive Standard Cleaning intensity level
auto_clean Every Time/Only When High Every Time Cleaning trigger condition
run_timing After Queue/Before Queue/Both After Queue When to perform cleaning
force_run 0-999 0 Manual trigger (change value to execute)

GPU Monitor Settings

Parameter Range Default Description
monitoring_enabled On/Off On Enable/disable real-time monitoring
update_interval 0.1-10.0 1.0 Update frequency in seconds
history_length 10-300 60 Number of data points to keep
warning_threshold 50.0-95.0 80.0 Memory usage warning percentage
refresh_trigger 0-9999 0 Manual refresh trigger

๐Ÿ”ง Advanced Features

Automatic Dependency Installation

The nodes automatically install required dependencies (GPUtil) on first run.

Background Monitoring

The GPU Monitor runs in a separate thread to provide real-time data without blocking ComfyUI.

ComfyUI Integration

Automatically hooks into ComfyUI's queue execution system for seamless VRAM management.

Terminal Logging

Comprehensive logging system provides detailed information about all operations.

๐Ÿ› Troubleshooting

Common Issues

  1. "GPU not found" error

    • Ensure GPUtil is installed: pip install GPUtil
    • Check if your GPU is properly detected by your system
  2. VRAM cleaning not working

    • Verify PyTorch CUDA support: torch.cuda.is_available()
    • Check if CUDA drivers are properly installed
  3. Monitoring not updating

    • Increase the update interval
    • Check ComfyUI terminal for error messages

Getting Help

If you encounter issues:

  1. Check the ComfyUI terminal for error messages
  2. Open an issue on GitHub with detailed information
  3. Join our community discussions

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • ComfyUI team for the amazing framework
  • GPUtil library for GPU monitoring capabilities
  • Community feedback and suggestions

๐Ÿ”— Links


Made with โค๏ธ by StrawberryFist | ๐Ÿ“ Optimizing your ComfyUI experience!

About

"An optimizer custom node for ComfyUI that ensures each queue execution starts in an optimal state by clearing unused VRAM and unnecessary resources between runs."

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages