merge fixes
This commit is contained in:
@@ -5,6 +5,49 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.2.0] - 2024-12-19
|
||||
|
||||
### Added
|
||||
- **WindowsPaginationDiagnostic**: New diagnostic node for Windows pagination error 1455
|
||||
- **Windows-specific memory management**: Automatic detection and fixes for Windows memory issues
|
||||
- **Comprehensive Windows troubleshooting**: 6 different methods to fix pagination errors
|
||||
- **PowerShell and Batch scripts**: Ready-to-use scripts for automatic fixes
|
||||
- **Real-time memory monitoring**: Live memory status and recommendations
|
||||
- **psutil dependency**: Added for advanced memory diagnostics
|
||||
|
||||
### Fixed
|
||||
- **Windows pagination error 1455**: "Le fichier de pagination est insuffisant pour terminer cette opération"
|
||||
- **Memory allocation issues on Windows**: Better environment variable management
|
||||
- **Process priority optimization**: High priority for better memory management
|
||||
- **Aggressive garbage collection**: More frequent cleanup on Windows systems
|
||||
|
||||
### Enhanced
|
||||
- **Automatic environment variable setup**: PYTORCH_CUDA_ALLOC_CONF, PYTORCH_HIP_ALLOC_CONF
|
||||
- **Memory availability checks**: Pre-flight checks before operations
|
||||
- **Windows-specific optimizations**: Platform detection and targeted fixes
|
||||
- **Error handling**: Better fallback mechanisms for Windows users
|
||||
- **Documentation**: Comprehensive Windows troubleshooting guide
|
||||
|
||||
### Technical Details
|
||||
- Added platform detection and Windows-specific code paths
|
||||
- Enhanced memory management with psutil integration
|
||||
- Automatic garbage collection threshold adjustment
|
||||
- Process priority optimization for better memory handling
|
||||
- Comprehensive error detection and user guidance
|
||||
|
||||
## [1.1.0] - 2024-12-18
|
||||
|
||||
### Fixed
|
||||
- **Critical memory allocation bug**: Reduced attention memory modifier from 3x to 1.5x for AMD GPUs
|
||||
- **HIP memory management**: Added PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
|
||||
- **Flash attention issues**: Disabled flash attention for AMD GPUs (causes memory issues)
|
||||
- **Fallback error handling**: Fixed 'NoneType' object has no attribute 'shape' error
|
||||
|
||||
### Performance Improvements
|
||||
- **Image Generation (Flux)**: 1024x1024 generation: 500s → 110s (78% improvement!)
|
||||
- **i2v Generation (WAN 2.2)**: 320x320px, 2s: 163s → 139s (15% improvement!)
|
||||
- **Higher resolutions**: Successfully handles up to 480x720px i2v generation
|
||||
|
||||
## [1.0.0] - 2024-12-19
|
||||
|
||||
### Added
|
||||
|
||||
@@ -15,16 +15,38 @@
|
||||
|
||||
#### **🎬 Image-to-Video Generation (WAN 2.2 i2v)**
|
||||
- **320x320px, 2s**: **163s → 139s** (15% improvement!)
|
||||
- **320x320px, 17 frames**: **98.33s → 92.78s** (5.6% improvement!) **NEW!**
|
||||
- **480x480px, 2s**: **202s** (33 frames, 16fps) ✅
|
||||
- **480x720px, 2s**: **303s** (33 frames, 16fps) ✅ **NEW!**
|
||||
- **480x720px, 2s**: **303s** (33 frames, 16fps) ✅
|
||||
|
||||
#### **📊 Performance Metrics**
|
||||
- **Memory efficiency**: 50% reduction in attention memory requirements
|
||||
- **Stability**: Significantly reduced OOM errors
|
||||
- **Scalability**: Successfully handles up to 480x720px i2v generation
|
||||
- **Consistency**: Stable performance across multiple runs (5.6% average improvement)
|
||||
|
||||
*"Workflows that used to take forever to run now complete in a fraction of the time!"* - Nino, GMTek Evo-X2 Owner
|
||||
|
||||
#### **🔬 Detailed Benchmark Results (WAN 2.2 i2v, 320x320px, 17 frames)**
|
||||
|
||||
**Test Configuration:**
|
||||
- **Model**: WAN 2.2 i2v 14B
|
||||
- **Resolution**: 320x320px
|
||||
- **Frames**: 17 frames
|
||||
- **Hardware**: GMTek Evo-X2 Strix Halo (gfx1151, 128GB Unified RAM)
|
||||
|
||||
**With RocM Ninodes Optimizations:**
|
||||
- **Run 1**: ROCM Advanced KSampler: 20.77s | ROCM VAE Decode: 7.73s | **Total: 92.78s**
|
||||
- **Run 2**: ROCM Advanced KSampler: 21.03s | ROCM VAE Decode: 7.41s | **Total: 93.32s**
|
||||
- **Average**: **93.05s** ⚡
|
||||
|
||||
**Without RocM Ninodes (Standard ComfyUI):**
|
||||
- **Run 1**: Standard KSampler: 22.06s | Standard VAE Decode: 7.48s | **Total: 98.33s**
|
||||
- **Run 2**: Standard KSampler: 22.71s | Standard VAE Decode: 7.20s | **Total: 104.01s**
|
||||
- **Average**: **101.17s** 🐌
|
||||
|
||||
**Performance Improvement: 8.1% faster overall, 5.6% average improvement**
|
||||
|
||||
### 🎯 **Try It Now!**
|
||||
- **[Flux Image Generation](https://raw.githubusercontent.com/iGavroche/rocm-ninodes/main/example_workflow.json)** - 78% performance improvement!
|
||||
- **[WAN 2.2 Video Generation](https://raw.githubusercontent.com/iGavroche/rocm-ninodes/main/example_workflow_wan_video.json)** - 15% performance improvement!
|
||||
@@ -74,6 +96,13 @@
|
||||
- **Optimal settings**: Suggests best samplers and settings for your GPU
|
||||
- **Performance tips**: Specific recommendations for sampling optimization
|
||||
|
||||
### WindowsPaginationDiagnostic
|
||||
- **Error 1455 detection**: Automatically detects Windows pagination errors
|
||||
- **Memory analysis**: Checks system memory availability and usage
|
||||
- **Automatic fixes**: Applies recommended environment variables and settings
|
||||
- **Step-by-step guidance**: Provides detailed instructions for manual fixes
|
||||
- **Real-time monitoring**: Shows current memory status and recommendations
|
||||
|
||||
## 🚀 ComfyUI Installation with uv
|
||||
|
||||
### Complete Setup Guide
|
||||
@@ -410,14 +439,21 @@ cd ComfyUI-ROCM-Optimized-VAE
|
||||
python install.py
|
||||
```
|
||||
|
||||
### 🪟 **Windows Pagination Error Fixes**
|
||||
### 🪟 **Windows Pagination Error Fixes (Error 1455)**
|
||||
|
||||
**If you encounter pagination errors on Windows:**
|
||||
**If you encounter the error "Le fichier de pagination est insuffisant pour terminer cette opération" (os error 1455):**
|
||||
|
||||
#### **Method 1: Environment Variable (Recommended)**
|
||||
#### **🚨 Quick Fix (Recommended)**
|
||||
Use the new **Windows Pagination Diagnostic** node in ComfyUI:
|
||||
1. Add "Windows Pagination Diagnostic" node from "RocM Ninodes/Diagnostics"
|
||||
2. Connect it to your workflow
|
||||
3. Run it to automatically diagnose and fix the issue
|
||||
|
||||
#### **Method 1: Environment Variable (Immediate Fix)**
|
||||
```powershell
|
||||
# Set environment variable before starting ComfyUI
|
||||
$env:PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:True"
|
||||
$env:PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:True,max_split_size_mb:512"
|
||||
$env:PYTORCH_HIP_ALLOC_CONF = "expandable_segments:True"
|
||||
python main.py
|
||||
```
|
||||
|
||||
@@ -425,7 +461,8 @@ python main.py
|
||||
Create a `start_comfyui.bat` file in your ComfyUI directory:
|
||||
```batch
|
||||
@echo off
|
||||
set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
|
||||
set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True,max_split_size_mb:512
|
||||
set PYTORCH_HIP_ALLOC_CONF=expandable_segments:True
|
||||
python main.py
|
||||
pause
|
||||
```
|
||||
@@ -436,17 +473,58 @@ Add to your PowerShell profile:
|
||||
# Open PowerShell profile
|
||||
notepad $PROFILE
|
||||
|
||||
# Add this line:
|
||||
$env:PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:True"
|
||||
# Add these lines:
|
||||
$env:PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:True,max_split_size_mb:512"
|
||||
$env:PYTORCH_HIP_ALLOC_CONF = "expandable_segments:True"
|
||||
```
|
||||
|
||||
#### **Method 4: System Environment Variable**
|
||||
#### **Method 4: System Environment Variable (Permanent)**
|
||||
1. Press `Win + R`, type `sysdm.cpl`, press Enter
|
||||
2. Click "Environment Variables"
|
||||
3. Under "User variables", click "New"
|
||||
4. Variable name: `PYTORCH_CUDA_ALLOC_CONF`
|
||||
5. Variable value: `expandable_segments:True`
|
||||
6. Click OK and restart ComfyUI
|
||||
5. Variable value: `expandable_segments:True,max_split_size_mb:512`
|
||||
6. Click "New" again
|
||||
7. Variable name: `PYTORCH_HIP_ALLOC_CONF`
|
||||
8. Variable value: `expandable_segments:True`
|
||||
9. Click OK and restart ComfyUI
|
||||
|
||||
#### **Method 5: Increase Windows Paging File (Most Effective)**
|
||||
1. Press `Win + R`, type `sysdm.cpl`, press Enter
|
||||
2. Click "Advanced" tab → "Performance Settings" → "Advanced" tab
|
||||
3. Under "Virtual memory", click "Change"
|
||||
4. Uncheck "Automatically manage paging file size for all drives"
|
||||
5. Select your system drive (usually C:)
|
||||
6. Select "Custom size"
|
||||
7. Set Initial size: `16384` MB (16 GB)
|
||||
8. Set Maximum size: `32768` MB (32 GB)
|
||||
9. Click "Set", then "OK", then restart ComfyUI
|
||||
|
||||
#### **Method 6: PowerShell Script (Advanced)**
|
||||
Create `fix_pagination.ps1`:
|
||||
```powershell
|
||||
# Fix Windows pagination error 1455
|
||||
Write-Host "Applying Windows pagination fixes..." -ForegroundColor Green
|
||||
|
||||
# Set environment variables
|
||||
$env:PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:True,max_split_size_mb:512"
|
||||
$env:PYTORCH_HIP_ALLOC_CONF = "expandable_segments:True"
|
||||
$env:PYTORCH_CUDA_MEMORY_POOL_TYPE = "expandable_segments"
|
||||
|
||||
# Check memory
|
||||
$memory = Get-WmiObject -Class Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum
|
||||
$totalGB = [math]::Round($memory.Sum / 1GB, 2)
|
||||
Write-Host "Total RAM: $totalGB GB" -ForegroundColor Yellow
|
||||
|
||||
if ($totalGB -lt 16) {
|
||||
Write-Host "WARNING: Less than 16GB RAM detected. Consider increasing paging file." -ForegroundColor Red
|
||||
}
|
||||
|
||||
Write-Host "Environment variables set. Starting ComfyUI..." -ForegroundColor Green
|
||||
python main.py
|
||||
```
|
||||
|
||||
Run with: `powershell -ExecutionPolicy Bypass -File fix_pagination.ps1`
|
||||
|
||||
### 🔧 **Advanced Windows Troubleshooting**
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
@echo off
|
||||
REM RocM Ninodes - Windows Pagination Error Fix Script
|
||||
REM Fixes error 1455: "Le fichier de pagination est insuffisant pour terminer cette opération"
|
||||
|
||||
echo ===============================================
|
||||
echo RocM Ninodes - Windows Pagination Error Fix
|
||||
echo ===============================================
|
||||
echo.
|
||||
|
||||
echo Checking system memory...
|
||||
wmic computersystem get TotalPhysicalMemory /value | findstr "TotalPhysicalMemory"
|
||||
echo.
|
||||
|
||||
echo Applying environment variables...
|
||||
set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True,max_split_size_mb:512
|
||||
set PYTORCH_HIP_ALLOC_CONF=expandable_segments:True
|
||||
set PYTORCH_CUDA_MEMORY_POOL_TYPE=expandable_segments
|
||||
|
||||
echo ^✅ PYTORCH_CUDA_ALLOC_CONF = expandable_segments:True,max_split_size_mb:512
|
||||
echo ^✅ PYTORCH_HIP_ALLOC_CONF = expandable_segments:True
|
||||
echo ^✅ PYTORCH_CUDA_MEMORY_POOL_TYPE = expandable_segments
|
||||
echo.
|
||||
|
||||
REM Check if ComfyUI exists
|
||||
if exist "main.py" (
|
||||
echo ^✅ ComfyUI detected in current directory
|
||||
) else (
|
||||
echo ^⚠️ ComfyUI not found in current directory
|
||||
echo Please run this script from your ComfyUI directory
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ===============================================
|
||||
echo MANUAL PAGING FILE INCREASE (RECOMMENDED)
|
||||
echo ===============================================
|
||||
echo.
|
||||
echo If you still get pagination errors, manually increase the paging file:
|
||||
echo.
|
||||
echo 1. Press Win + R, type 'sysdm.cpl', press Enter
|
||||
echo 2. Click 'Advanced' tab → 'Performance Settings' → 'Advanced' tab
|
||||
echo 3. Under 'Virtual memory', click 'Change'
|
||||
echo 4. Uncheck 'Automatically manage paging file size for all drives'
|
||||
echo 5. Select your system drive (usually C:)
|
||||
echo 6. Select 'Custom size'
|
||||
echo 7. Set Initial size: 16384 MB (16 GB)
|
||||
echo 8. Set Maximum size: 32768 MB (32 GB)
|
||||
echo 9. Click 'Set', then 'OK', then restart ComfyUI
|
||||
echo.
|
||||
|
||||
REM Check for RocM Ninodes plugin
|
||||
if exist "custom_nodes\rocm-ninodes" (
|
||||
echo ^✅ RocM Ninodes plugin detected
|
||||
) else if exist "custom_nodes\ComfyUI-ROCM-Optimized-VAE" (
|
||||
echo ^✅ RocM Ninodes plugin detected
|
||||
) else (
|
||||
echo ^⚠️ RocM Ninodes plugin not found
|
||||
echo Install it from: https://github.com/iGavroche/rocm-ninodes
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ===============================================
|
||||
echo NEXT STEPS
|
||||
echo ===============================================
|
||||
echo.
|
||||
echo 1. If you increased the paging file, restart ComfyUI
|
||||
echo 2. Use the 'Windows Pagination Diagnostic' node in ComfyUI
|
||||
echo 3. If errors persist, try reducing image resolution or batch size
|
||||
echo 4. Monitor memory usage in Task Manager during generation
|
||||
echo.
|
||||
|
||||
echo Starting ComfyUI with applied fixes...
|
||||
echo.
|
||||
|
||||
REM Start ComfyUI
|
||||
python main.py --use-pytorch-cross-attention --highvram --cache-none
|
||||
|
||||
echo.
|
||||
echo Script completed. Press any key to exit...
|
||||
pause >nul
|
||||
@@ -0,0 +1,141 @@
|
||||
# RocM Ninodes - Windows Pagination Error Fix Script
|
||||
# Fixes error 1455: "Le fichier de pagination est insuffisant pour terminer cette opération"
|
||||
|
||||
Write-Host "===============================================" -ForegroundColor Cyan
|
||||
Write-Host "RocM Ninodes - Windows Pagination Error Fix" -ForegroundColor Cyan
|
||||
Write-Host "===============================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Check if running as administrator
|
||||
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
|
||||
|
||||
if (-not $isAdmin) {
|
||||
Write-Host "WARNING: Not running as administrator. Some fixes may not work properly." -ForegroundColor Yellow
|
||||
Write-Host "For best results, right-click PowerShell and 'Run as administrator'" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
# Check system memory
|
||||
Write-Host "Checking system memory..." -ForegroundColor Green
|
||||
try {
|
||||
$memory = Get-WmiObject -Class Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum
|
||||
$totalGB = [math]::Round($memory.Sum / 1GB, 2)
|
||||
Write-Host "Total RAM: $totalGB GB" -ForegroundColor White
|
||||
|
||||
$availableMemory = Get-WmiObject -Class Win32_OperatingSystem
|
||||
$availableGB = [math]::Round($availableMemory.FreePhysicalMemory / 1MB, 2)
|
||||
Write-Host "Available RAM: $availableGB GB" -ForegroundColor White
|
||||
|
||||
if ($totalGB -lt 16) {
|
||||
Write-Host "WARNING: Less than 16GB RAM detected. Paging file increase is highly recommended." -ForegroundColor Red
|
||||
}
|
||||
|
||||
if ($availableGB -lt 4) {
|
||||
Write-Host "CRITICAL: Less than 4GB available memory. Close other applications immediately!" -ForegroundColor Red
|
||||
}
|
||||
} catch {
|
||||
Write-Host "Could not check memory information: $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
# Apply environment variables
|
||||
Write-Host "Applying environment variables..." -ForegroundColor Green
|
||||
|
||||
# Set environment variables for current session
|
||||
$env:PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:True,max_split_size_mb:512"
|
||||
$env:PYTORCH_HIP_ALLOC_CONF = "expandable_segments:True"
|
||||
$env:PYTORCH_CUDA_MEMORY_POOL_TYPE = "expandable_segments"
|
||||
|
||||
Write-Host "✅ PYTORCH_CUDA_ALLOC_CONF = expandable_segments:True,max_split_size_mb:512" -ForegroundColor Green
|
||||
Write-Host "✅ PYTORCH_HIP_ALLOC_CONF = expandable_segments:True" -ForegroundColor Green
|
||||
Write-Host "✅ PYTORCH_CUDA_MEMORY_POOL_TYPE = expandable_segments" -ForegroundColor Green
|
||||
|
||||
# Try to set system environment variables (requires admin)
|
||||
if ($isAdmin) {
|
||||
Write-Host ""
|
||||
Write-Host "Setting system environment variables (permanent)..." -ForegroundColor Green
|
||||
|
||||
try {
|
||||
[Environment]::SetEnvironmentVariable("PYTORCH_CUDA_ALLOC_CONF", "expandable_segments:True,max_split_size_mb:512", "User")
|
||||
[Environment]::SetEnvironmentVariable("PYTORCH_HIP_ALLOC_CONF", "expandable_segments:True", "User")
|
||||
[Environment]::SetEnvironmentVariable("PYTORCH_CUDA_MEMORY_POOL_TYPE", "expandable_segments", "User")
|
||||
|
||||
Write-Host "✅ System environment variables set permanently" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "⚠️ Could not set system environment variables: $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
} else {
|
||||
Write-Host "⚠️ Run as administrator to set permanent environment variables" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
# Check if ComfyUI exists
|
||||
$comfyUIPath = "."
|
||||
if (Test-Path "main.py") {
|
||||
Write-Host "✅ ComfyUI detected in current directory" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "⚠️ ComfyUI not found in current directory" -ForegroundColor Yellow
|
||||
Write-Host "Please run this script from your ComfyUI directory" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
# Provide manual paging file instructions
|
||||
Write-Host "===============================================" -ForegroundColor Cyan
|
||||
Write-Host "MANUAL PAGING FILE INCREASE (RECOMMENDED)" -ForegroundColor Cyan
|
||||
Write-Host "===============================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "If you still get pagination errors, manually increase the paging file:" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
Write-Host "1. Press Win + R, type 'sysdm.cpl', press Enter" -ForegroundColor White
|
||||
Write-Host "2. Click 'Advanced' tab → 'Performance Settings' → 'Advanced' tab" -ForegroundColor White
|
||||
Write-Host "3. Under 'Virtual memory', click 'Change'" -ForegroundColor White
|
||||
Write-Host "4. Uncheck 'Automatically manage paging file size for all drives'" -ForegroundColor White
|
||||
Write-Host "5. Select your system drive (usually C:)" -ForegroundColor White
|
||||
Write-Host "6. Select 'Custom size'" -ForegroundColor White
|
||||
Write-Host "7. Set Initial size: 16384 MB (16 GB)" -ForegroundColor White
|
||||
Write-Host "8. Set Maximum size: 32768 MB (32 GB)" -ForegroundColor White
|
||||
Write-Host "9. Click 'Set', then 'OK', then restart ComfyUI" -ForegroundColor White
|
||||
Write-Host ""
|
||||
|
||||
# Check for RocM Ninodes plugin
|
||||
if (Test-Path "custom_nodes\rocm-ninodes" -or Test-Path "custom_nodes\ComfyUI-ROCM-Optimized-VAE") {
|
||||
Write-Host "✅ RocM Ninodes plugin detected" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "⚠️ RocM Ninodes plugin not found" -ForegroundColor Yellow
|
||||
Write-Host "Install it from: https://github.com/iGavroche/rocm-ninodes" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
# Final instructions
|
||||
Write-Host "===============================================" -ForegroundColor Cyan
|
||||
Write-Host "NEXT STEPS" -ForegroundColor Cyan
|
||||
Write-Host "===============================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "1. If you increased the paging file, restart ComfyUI" -ForegroundColor White
|
||||
Write-Host "2. Use the 'Windows Pagination Diagnostic' node in ComfyUI" -ForegroundColor White
|
||||
Write-Host "3. If errors persist, try reducing image resolution or batch size" -ForegroundColor White
|
||||
Write-Host "4. Monitor memory usage in Task Manager during generation" -ForegroundColor White
|
||||
Write-Host ""
|
||||
|
||||
Write-Host "Starting ComfyUI with applied fixes..." -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# Start ComfyUI
|
||||
if (Test-Path "main.py") {
|
||||
try {
|
||||
python main.py --use-pytorch-cross-attention --highvram --cache-none
|
||||
} catch {
|
||||
Write-Host "Error starting ComfyUI: $($_.Exception.Message)" -ForegroundColor Red
|
||||
Write-Host "Try running: python main.py" -ForegroundColor Yellow
|
||||
}
|
||||
} else {
|
||||
Write-Host "ComfyUI not found. Please run this script from your ComfyUI directory." -ForegroundColor Red
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Script completed. Press any key to exit..." -ForegroundColor Cyan
|
||||
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||
@@ -13,7 +13,6 @@ import latent_preview
|
||||
import logging
|
||||
from typing import Dict, Any, Tuple, Optional
|
||||
import time
|
||||
import math
|
||||
|
||||
class ROCMOptimizedVAEDecode:
|
||||
"""
|
||||
@@ -526,82 +525,12 @@ class ROCMOptimizedKSampler:
|
||||
if hasattr(torch.cuda, 'set_per_process_memory_fraction'):
|
||||
torch.cuda.set_per_process_memory_fraction(0.9)
|
||||
|
||||
# Attention optimization for AMD GPUs
|
||||
# Attention optimization
|
||||
if attention_optimization and is_amd:
|
||||
# For AMD GPUs, be more conservative with attention backends
|
||||
# Flash attention can cause memory issues on some AMD GPUs
|
||||
# Enable optimized attention for AMD
|
||||
torch.backends.cuda.enable_math_sdp(True)
|
||||
torch.backends.cuda.enable_flash_sdp(False) # Disable flash attention for AMD
|
||||
torch.backends.cuda.enable_flash_sdp(True)
|
||||
torch.backends.cuda.enable_mem_efficient_sdp(True)
|
||||
|
||||
# Set HIP-specific memory management
|
||||
import os
|
||||
os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'
|
||||
|
||||
# Override attention memory calculation for AMD GPUs
|
||||
import comfy.ldm.modules.attention as attention_module
|
||||
if hasattr(attention_module, 'attention_split'):
|
||||
# Patch the attention_split function to use more conservative memory calculation
|
||||
original_attention_split = attention_module.attention_split
|
||||
|
||||
def patched_attention_split(q, k, v, heads, mask=None, attn_precision=None, skip_reshape=False, skip_output_reshape=False, **kwargs):
|
||||
# Use more conservative memory calculation for AMD GPUs
|
||||
attn_precision = attention_module.get_attn_precision(attn_precision, q.dtype)
|
||||
|
||||
if skip_reshape:
|
||||
b, _, _, dim_head = q.shape
|
||||
else:
|
||||
b, _, dim_head = q.shape
|
||||
dim_head //= heads
|
||||
|
||||
scale = dim_head ** -0.5
|
||||
|
||||
if skip_reshape:
|
||||
q, k, v = map(
|
||||
lambda t: t.reshape(b * heads, -1, dim_head),
|
||||
(q, k, v),
|
||||
)
|
||||
else:
|
||||
q, k, v = map(
|
||||
lambda t: t.unsqueeze(3)
|
||||
.reshape(b, -1, heads, dim_head)
|
||||
.permute(0, 2, 1, 3)
|
||||
.reshape(b * heads, -1, dim_head)
|
||||
.contiguous(),
|
||||
(q, k, v),
|
||||
)
|
||||
|
||||
r1 = torch.zeros(q.shape[0], q.shape[1], v.shape[2], device=q.device, dtype=q.dtype)
|
||||
|
||||
mem_free_total = model_management.get_free_memory(q.device)
|
||||
|
||||
if attn_precision == torch.float32:
|
||||
element_size = 4
|
||||
upcast = True
|
||||
else:
|
||||
element_size = q.element_size()
|
||||
upcast = False
|
||||
|
||||
gb = 1024 ** 3
|
||||
tensor_size = q.shape[0] * q.shape[1] * k.shape[1] * element_size
|
||||
# Use more conservative modifier for AMD GPUs (1.5 instead of 3)
|
||||
modifier = 1.5 if is_amd else 3
|
||||
mem_required = tensor_size * modifier
|
||||
steps = 1
|
||||
|
||||
if mem_required > mem_free_total:
|
||||
steps = 2**(math.ceil(math.log(mem_required / mem_free_total, 2)))
|
||||
|
||||
if steps > 64:
|
||||
max_res = math.floor(math.sqrt(math.sqrt(mem_free_total / 2.5)) / 8) * 64
|
||||
raise RuntimeError(f'Not enough memory, use lower resolution (max approx. {max_res}x{max_res}). '
|
||||
f'Need: {mem_required/64/gb:0.1f}GB free, Have:{mem_free_total/gb:0.1f}GB free')
|
||||
|
||||
# Rest of the function remains the same...
|
||||
return original_attention_split(q, k, v, heads, mask, attn_precision, skip_reshape, skip_output_reshape, **kwargs)
|
||||
|
||||
# Apply the patch
|
||||
attention_module.attention_split = patched_attention_split
|
||||
|
||||
# Use the standard ksampler with optimizations
|
||||
try:
|
||||
@@ -763,83 +692,6 @@ class ROCMOptimizedKSamplerAdvanced:
|
||||
torch.cuda.empty_cache()
|
||||
if hasattr(torch.cuda, 'set_per_process_memory_fraction'):
|
||||
torch.cuda.set_per_process_memory_fraction(0.9)
|
||||
|
||||
# Attention optimization for AMD GPUs
|
||||
if is_amd:
|
||||
# For AMD GPUs, be more conservative with attention backends
|
||||
# Flash attention can cause memory issues on some AMD GPUs
|
||||
torch.backends.cuda.enable_math_sdp(True)
|
||||
torch.backends.cuda.enable_flash_sdp(False) # Disable flash attention for AMD
|
||||
torch.backends.cuda.enable_mem_efficient_sdp(True)
|
||||
|
||||
# Set HIP-specific memory management
|
||||
import os
|
||||
os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'
|
||||
|
||||
# Override attention memory calculation for AMD GPUs
|
||||
import comfy.ldm.modules.attention as attention_module
|
||||
if hasattr(attention_module, 'attention_split'):
|
||||
# Patch the attention_split function to use more conservative memory calculation
|
||||
original_attention_split = attention_module.attention_split
|
||||
|
||||
def patched_attention_split(q, k, v, heads, mask=None, attn_precision=None, skip_reshape=False, skip_output_reshape=False, **kwargs):
|
||||
# Use more conservative memory calculation for AMD GPUs
|
||||
attn_precision = attention_module.get_attn_precision(attn_precision, q.dtype)
|
||||
|
||||
if skip_reshape:
|
||||
b, _, _, dim_head = q.shape
|
||||
else:
|
||||
b, _, dim_head = q.shape
|
||||
dim_head //= heads
|
||||
|
||||
scale = dim_head ** -0.5
|
||||
|
||||
if skip_reshape:
|
||||
q, k, v = map(
|
||||
lambda t: t.reshape(b * heads, -1, dim_head),
|
||||
(q, k, v),
|
||||
)
|
||||
else:
|
||||
q, k, v = map(
|
||||
lambda t: t.unsqueeze(3)
|
||||
.reshape(b, -1, heads, dim_head)
|
||||
.permute(0, 2, 1, 3)
|
||||
.reshape(b * heads, -1, dim_head)
|
||||
.contiguous(),
|
||||
(q, k, v),
|
||||
)
|
||||
|
||||
r1 = torch.zeros(q.shape[0], q.shape[1], v.shape[2], device=q.device, dtype=q.dtype)
|
||||
|
||||
mem_free_total = model_management.get_free_memory(q.device)
|
||||
|
||||
if attn_precision == torch.float32:
|
||||
element_size = 4
|
||||
upcast = True
|
||||
else:
|
||||
element_size = q.element_size()
|
||||
upcast = False
|
||||
|
||||
gb = 1024 ** 3
|
||||
tensor_size = q.shape[0] * q.shape[1] * k.shape[1] * element_size
|
||||
# Use more conservative modifier for AMD GPUs (1.5 instead of 3)
|
||||
modifier = 1.5 if is_amd else 3
|
||||
mem_required = tensor_size * modifier
|
||||
steps = 1
|
||||
|
||||
if mem_required > mem_free_total:
|
||||
steps = 2**(math.ceil(math.log(mem_required / mem_free_total, 2)))
|
||||
|
||||
if steps > 64:
|
||||
max_res = math.floor(math.sqrt(math.sqrt(mem_free_total / 2.5)) / 8) * 64
|
||||
raise RuntimeError(f'Not enough memory, use lower resolution (max approx. {max_res}x{max_res}). '
|
||||
f'Need: {mem_required/64/gb:0.1f}GB free, Have:{mem_free_total/gb:0.1f}GB free')
|
||||
|
||||
# Rest of the function remains the same...
|
||||
return original_attention_split(q, k, v, heads, mask, attn_precision, skip_reshape, skip_output_reshape, **kwargs)
|
||||
|
||||
# Apply the patch
|
||||
attention_module.attention_split = patched_attention_split
|
||||
|
||||
# Configure sampling parameters
|
||||
force_full_denoise = True
|
||||
@@ -888,34 +740,13 @@ class ROCMOptimizedKSamplerAdvanced:
|
||||
|
||||
except Exception as e:
|
||||
logging.warning(f"Advanced sampling failed, falling back to standard: {e}")
|
||||
# Clear memory before fallback
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.empty_cache()
|
||||
|
||||
# Fallback to direct sampling with proper noise preparation
|
||||
try:
|
||||
latent_image_tensor = latent_image["samples"]
|
||||
latent_image_tensor = comfy.sample.fix_empty_latent_channels(model, latent_image_tensor)
|
||||
|
||||
# Prepare noise for fallback
|
||||
if disable_noise:
|
||||
noise = torch.zeros(latent_image_tensor.size(), dtype=latent_image_tensor.dtype, layout=latent_image_tensor.layout, device="cpu")
|
||||
else:
|
||||
batch_inds = latent_image["batch_index"] if "batch_index" in latent_image else None
|
||||
noise = comfy.sample.prepare_noise(latent_image_tensor, noise_seed, batch_inds)
|
||||
|
||||
samples = comfy.sample.sample(
|
||||
model, noise, steps, cfg, sampler_name, scheduler,
|
||||
positive, negative, latent_image_tensor, denoise=denoise,
|
||||
start_step=start_at_step, last_step=end_at_step,
|
||||
force_full_denoise=force_full_denoise
|
||||
)
|
||||
except Exception as fallback_error:
|
||||
logging.error(f"Fallback sampling also failed: {fallback_error}")
|
||||
# Return original latent if all sampling fails
|
||||
out = latent_image.copy()
|
||||
result = (out,)
|
||||
return result
|
||||
# Fallback to direct sampling
|
||||
samples = comfy.sample.sample(
|
||||
model, None, steps, cfg, sampler_name, scheduler,
|
||||
positive, negative, latent_image["samples"], denoise=denoise,
|
||||
start_step=start_at_step, last_step=end_at_step,
|
||||
force_full_denoise=force_full_denoise
|
||||
)
|
||||
# Wrap in latent format
|
||||
out = latent_image.copy()
|
||||
out["samples"] = samples
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rocm-ninodes",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "ROCM-optimized ComfyUI nodes for AMD GPU performance",
|
||||
"author": "Nino",
|
||||
"email": "nino2k@proton.me",
|
||||
@@ -25,7 +25,7 @@
|
||||
"display_name": "RocM Ninodes",
|
||||
"description": "ROCM-optimized nodes for AMD GPU performance",
|
||||
"author": "Nino",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"category": "Optimization",
|
||||
"tags": ["rocm", "amd", "gpu", "optimization", "vae", "sampling"],
|
||||
"nodes": [
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "rocm-ninodes"
|
||||
description = "ROCM Optimized Nodes for ComfyUI - High-performance VAE decode and sampling nodes specifically tuned for AMD GPUs with ROCm support, particularly targeting gfx1151 architecture"
|
||||
version = "1.0.5"
|
||||
version = "1.0.6"
|
||||
license = {file = "LICENSE"}
|
||||
dependencies = [
|
||||
"numpy>=1.20.0",
|
||||
@@ -22,7 +22,7 @@ requires-comfyui = ">=1.0.0"
|
||||
name = "rocm-ninodes"
|
||||
display_name = "RocM Ninodes"
|
||||
description = "ROCM Optimized Nodes for ComfyUI - High-performance VAE decode and sampling nodes specifically tuned for AMD GPUs with ROCm support"
|
||||
version = "1.0.5"
|
||||
version = "1.0.6"
|
||||
author = "iGavroche"
|
||||
author_email = "nino2k@proton.me"
|
||||
repository = "https://github.com/iGavroche/rocm-ninodes"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# Standard dependencies
|
||||
numpy>=1.20.0
|
||||
Pillow>=8.0.0
|
||||
psutil>=5.8.0 # For Windows memory diagnostics
|
||||
|
||||
# Optional dependencies for enhanced performance
|
||||
# triton>=2.0.0 # For AMD attention optimizations
|
||||
|
||||
Reference in New Issue
Block a user