forked from Comfy-Org/ComfyUI
-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathcache-clean.bat
More file actions
168 lines (154 loc) · 5.05 KB
/
cache-clean.bat
File metadata and controls
168 lines (154 loc) · 5.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
@echo off
setlocal enabledelayedexpansion
echo ============================================
echo Cache Directory Cleanup Script
echo ============================================
echo.
echo This script will remove the following directories:
echo - ZLUDA ComputeCache
echo - MIOpen cache
echo - Triton cache
echo - TorchInductor temp files
echo - Torch/Triton/MIOpen/ZLUDA related cache subdirectories
echo - ComfyUI Triton and Inductor directories
echo.
REM Auto-detect COMFYUI_DIR if not set
if not defined COMFYUI_DIR (
echo COMFYUI_DIR not set, attempting auto-detection...
REM Check current directory first
if exist "comfyui-n.bat" (
set "COMFYUI_DIR=%CD%"
echo Found comfyui-n.bat in current directory: !COMFYUI_DIR!
) else (
REM Check script directory
set "SCRIPT_DIR=%~dp0"
if exist "!SCRIPT_DIR!comfyui-n.bat" (
set "COMFYUI_DIR=!SCRIPT_DIR!"
REM Remove trailing backslash if present
if "!COMFYUI_DIR:~-1!"=="\" set "COMFYUI_DIR=!COMFYUI_DIR:~0,-1!"
echo Found comfyui-n.bat in script directory: !COMFYUI_DIR!
) else (
echo comfyui-n.bat not found in current or script directory
)
)
)
if defined COMFYUI_DIR (
echo Using COMFYUI_DIR: !COMFYUI_DIR!
) else (
echo COMFYUI_DIR not detected - ComfyUI-specific directories will be skipped
)
echo.
echo.
echo Press 1 to continue or 2 to cancel...
choice /c 12 /n /m "Enter your choice:"
if errorlevel 2 exit /b
echo.
echo ============================================
echo Starting cleanup...
echo ============================================
echo.
REM ZLUDA ComputeCache
set "ZLUDA_CACHE=%USERPROFILE%\AppData\Local\ZLUDA\ComputeCache"
if exist "!ZLUDA_CACHE!" (
echo Removing ZLUDA ComputeCache...
rd /s /q "!ZLUDA_CACHE!" 2>nul
if exist "!ZLUDA_CACHE!" (
echo Warning: Could not remove !ZLUDA_CACHE!
) else (
echo Successfully removed !ZLUDA_CACHE!
)
) else (
echo ZLUDA ComputeCache not found: !ZLUDA_CACHE!
)
REM MIOpen cache
set "MIOPEN_CACHE=%USERPROFILE%\.miopen"
if exist "!MIOPEN_CACHE!" (
echo Removing MIOpen cache...
rd /s /q "!MIOPEN_CACHE!" 2>nul
if exist "!MIOPEN_CACHE!" (
echo Warning: Could not remove !MIOPEN_CACHE!
) else (
echo Successfully removed !MIOPEN_CACHE!
)
) else (
echo MIOpen cache not found: !MIOPEN_CACHE!
)
REM Triton cache
set "TRITON_CACHE=%USERPROFILE%\.triton"
if exist "!TRITON_CACHE!" (
echo Removing Triton cache...
rd /s /q "!TRITON_CACHE!" 2>nul
if exist "!TRITON_CACHE!" (
echo Warning: Could not remove !TRITON_CACHE!
) else (
echo Successfully removed !TRITON_CACHE!
)
) else (
echo Triton cache not found: !TRITON_CACHE!
)
REM TorchInductor temp files
set "TORCH_TEMP=%USERPROFILE%\AppData\Local\Temp"
echo Removing TorchInductor temp files...
for /d %%i in ("!TORCH_TEMP!\torchinductor_*") do (
echo Removing: %%i
rd /s /q "%%i" 2>nul
)
REM Cache subdirectories related to torch, triton, miopen, zluda
set "USER_CACHE=%USERPROFILE%\.cache"
if exist "!USER_CACHE!" (
echo Removing cache subdirectories related to torch, triton, miopen, zluda...
for /d %%i in ("!USER_CACHE!\*torch*" "!USER_CACHE!\*triton*" "!USER_CACHE!\*miopen*" "!USER_CACHE!\*zluda*") do (
if exist "%%i" (
echo Removing: %%i
rd /s /q "%%i" 2>nul
)
)
) else (
echo User cache directory not found: !USER_CACHE!
)
REM ComfyUI directories (if COMFYUI_DIR is set)
if defined COMFYUI_DIR (
set "COMFYUI_TRITON=!COMFYUI_DIR!\.triton"
if exist "!COMFYUI_TRITON!" (
echo Removing ComfyUI Triton directory...
rd /s /q "!COMFYUI_TRITON!" 2>nul
if exist "!COMFYUI_TRITON!" (
echo Warning: Could not remove !COMFYUI_TRITON!
) else (
echo Successfully removed !COMFYUI_TRITON!
)
) else (
echo ComfyUI Triton directory not found: !COMFYUI_TRITON!
)
set "COMFYUI_INDUCTOR=!COMFYUI_DIR!\.inductor"
if exist "!COMFYUI_INDUCTOR!" (
echo Removing ComfyUI Inductor directory...
rd /s /q "!COMFYUI_INDUCTOR!" 2>nul
if exist "!COMFYUI_INDUCTOR!" (
echo Warning: Could not remove !COMFYUI_INDUCTOR!
) else (
echo Successfully removed !COMFYUI_INDUCTOR!
)
) else (
echo ComfyUI Inductor directory not found: !COMFYUI_INDUCTOR!
)
) else (
echo COMFYUI_DIR not available, skipping ComfyUI-specific directories
)
echo.
echo ============================================
echo Cleanup completed!
echo ============================================
echo.
echo If you encountered any warnings above, you may need to:
echo - Close any running applications that might be using these directories
echo - Run this script as Administrator
echo - Manually delete the directories that couldn't be removed
echo.
:: Pause only if script was double-clicked (non-interactive mode)
echo %cmdcmdline% | findstr /i "\/c" >nul
if %errorlevel%==0 (
pause
) else (
pause
)