File size: 8,334 Bytes
e0f8896
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22695c3
e0f8896
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22695c3
 
 
 
 
 
 
 
 
 
 
 
e0f8896
 
36244f1
 
e0f8896
36244f1
 
 
e0f8896
36244f1
 
d4c0394
 
36244f1
 
d4c0394
 
36244f1
 
 
 
 
 
d4c0394
e0f8896
 
 
 
 
 
 
22695c3
e0f8896
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22695c3
e0f8896
 
 
22695c3
 
 
e0f8896
36244f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22695c3
36244f1
 
22695c3
36244f1
e0f8896
 
22695c3
e0f8896
 
 
 
93adebb
22695c3
93adebb
e0f8896
 
22695c3
e0f8896
 
22695c3
e0f8896
 
22695c3
e0f8896
 
 
 
22695c3
 
 
e0f8896
 
22695c3
e0f8896
 
95d0b5e
e0f8896
 
 
22695c3
95d0b5e
e0f8896
 
 
 
 
95d0b5e
e0f8896
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d4c0394
e0f8896
 
 
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
@echo off
setlocal enabledelayedexpansion



REM === SETUP PATHS ===
set "ROOT=%CD%"
set "PYTHON=%ROOT%\ComfyUI_windows_portable\python_embeded\python.exe"
set "COMFY_DIR=%ROOT%\ComfyUI_windows_portable\ComfyUI"
set "UPDATE_DIR=%ROOT%\ComfyUI_windows_portable\update"



REM === CHECK PYTHON ===
if not exist "%PYTHON%" (
    echo [ERROR] Python not found at: %PYTHON%
    pause
    exit /b 1
)



REM === SHOW SYSTEM INFO ===
echo.
echo ======== ComfyUI Nightly Installer (Interactive) ========
echo.



REM Python version
for /f "delims=" %%i in ('%PYTHON% -c "import platform; print(platform.python_version())"') do set PYVER=%%i
echo [INFO] Python Version: %PYVER%



REM Pip version
for /f "delims=" %%i in ('%PYTHON% -s -m pip --version') do set PIPVER=%%i
echo [INFO] Pip Version: %PIPVER%



REM CPU Cores
for /f %%i in ('powershell -NoProfile -Command "[Environment]::ProcessorCount"') do set "CPU_CORES=%%i"
if not defined CPU_CORES set "CPU_CORES=16"
echo [INFO] Detected CPU cores: %CPU_CORES%



REM CUDA Version
for /f "tokens=5 delims= " %%A in ('nvcc --version ^| findstr /C:"release"') do (
    for /f "tokens=1 delims=," %%B in ("%%A") do set cuda_version=%%B
)
for /f "tokens=1 delims=." %%a in ("%cuda_version%") do set cuda_major=%%a
for /f "tokens=2 delims=." %%b in ("%cuda_version%") do set cuda_minor=%%b
set cuda_version=!cuda_major!.!cuda_minor!
set "CLEAN_CUDA=%cuda_version:.=%"
echo [INFO] Detected CUDA version: %cuda_version%

echo.
pause



REM === PROMPTS ===



REM Update pip and setuptools?
set UPDATE_PIP=false
echo.
set /p "inp=Do you want to update pip and set setuptools to 70.2.0? (y/n): "
if /i "!inp!"=="y" set UPDATE_PIP=true



REM Update ComfyUI?
set UPDATE_COMFY=false
echo.
set /p "inp=Do you want to update ComfyUI via Git? (y/n): "
if /i "!inp!"=="y" set UPDATE_COMFY=true



REM Create Launcher?
set MAKE_LAUNCHER=false
echo.
set /p "inp=Do you want to generate a launcher batch file for FP16+Sage? (y/n): "
if /i "!inp!"=="y" set MAKE_LAUNCHER=true



REM Install PyTorch?
set INSTALL_TORCH=false
set TORCH_NIGHTLY=false
set TORCH_MANUAL=false
echo.
echo [1] Install PyTorch Nightly Latest (auto)
echo [2] Install PyTorch Nightly manually (specify version)
echo [3] Install PyTorch Stable
echo [0] Skip PyTorch installation
set /p "torch_choice=Choose PyTorch install option: "

if "%torch_choice%"=="1" (
    set INSTALL_TORCH=true
    set TORCH_NIGHTLY=true
    set TORCH_MANUAL=false
) else if "%torch_choice%"=="2" (
    set INSTALL_TORCH=true
    set TORCH_NIGHTLY=true
    set TORCH_MANUAL=true
) else if "%torch_choice%"=="3" (
    set INSTALL_TORCH=true
    set TORCH_NIGHTLY=false
    set TORCH_MANUAL=false
)



REM Install Triton?
set INSTALL_TRITON=false
echo.
echo [1] Install Nightly Triton
echo [2] Install Stable Triton
echo [3] Install LeoMaxwell Triton
echo [0] Skip Triton
set /p "triton_choice=Choose Triton version: "
if not "!triton_choice!"=="0" set INSTALL_TRITON=true



REM Install SageAttention?
set INSTALL_SAGE=false
echo.
echo [1] Install SageAttention v1 (PyPI)
echo [2] Install SageAttention v2 (Build from GitHub)
echo [0] Skip SageAttention
set /p "sage_choice=Choose SageAttention version: "
if not "!sage_choice!"=="0" set INSTALL_SAGE=true



REM === RUN CHOSEN INSTALLS ===

cd /d "%UPDATE_DIR%"

if "%UPDATE_PIP%"=="true" (
    echo [INFO] Updating pip and installing setuptools==70.2.0
    %PYTHON% -s -m pip install --upgrade pip setuptools==70.2.0
)

if "%INSTALL_TORCH%"=="true" (
    echo [INFO] Uninstalling old Torch versions
    %PYTHON% -s -m pip uninstall -y torch torchvision torchaudio

    if "%TORCH_NIGHTLY%"=="true" (
        if "%TORCH_MANUAL%"=="true" (
            echo.
            echo [INFO] Manual Nightly Installation
            echo Visit the following URLs to find the latest compatible versions:
            echo   Torch:      https://download.pytorch.org/whl/nightly/cu!CLEAN_CUDA!/torch/
            echo   Torchaudio: https://download.pytorch.org/whl/nightly/cu!CLEAN_CUDA!/torchaudio/
            echo   Torchvision:https://download.pytorch.org/whl/nightly/cu!CLEAN_CUDA!/torchvision/
            echo.

            set /p "TORCH_VER=Enter base torch version (e.g. torch-2.9.0.dev20250715): "
            set /p "AUDIO_VER=Enter base torchaudio version (e.g. torchaudio-2.8.0.dev20250716): "
            set /p "VISION_VER=Enter base torchvision version (e.g. torchvision-0.24.0.dev20250716): "

            for /f "tokens=1,2 delims=." %%a in ("%PYVER%") do (
                set "TMP_PY_MAJ=%%a"
                set "TMP_PY_MIN=%%b"
            )

            set "PY_MAJ=!TMP_PY_MAJ!"
            set "PY_MIN=!TMP_PY_MIN!"
            set "PY_TAG=cp!PY_MAJ!!PY_MIN!-cp!PY_MAJ!!PY_MIN!"
            set "WHEEL_SUFFIX=%%2Bcu!CLEAN_CUDA!-!PY_TAG!-win_amd64.whl"

            set "TORCH_URL=https://download.pytorch.org/whl/nightly/cu!CLEAN_CUDA!/!TORCH_VER!!WHEEL_SUFFIX!"
            set "AUDIO_URL=https://download.pytorch.org/whl/nightly/cu!CLEAN_CUDA!/!AUDIO_VER!!WHEEL_SUFFIX!"
            set "VISION_URL=https://download.pytorch.org/whl/nightly/cu!CLEAN_CUDA!/!VISION_VER!!WHEEL_SUFFIX!"

            echo.
            echo [INFO] Installing manually specified wheels...
            echo   Torch:      !TORCH_URL!
            echo   Torchaudio: !AUDIO_URL!
            echo   Torchvision:!VISION_URL!

            %PYTHON% -s -m pip install "!TORCH_URL!" "!AUDIO_URL!" "!VISION_URL!"
        ) else (
            echo [INFO] Installing PyTorch Nightly for CUDA %CLEAN_CUDA%
            %PYTHON% -s -m pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu%CLEAN_CUDA%
        )
    ) else (
        echo [INFO] Installing PyTorch Stable for CUDA %CLEAN_CUDA%
        %PYTHON% -s -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu%CLEAN_CUDA%
    )
)

if "%INSTALL_TRITON%"=="true" (
    echo [INFO] Uninstalling old Triton versions
    %PYTHON% -s -m pip uninstall -y triton triton-windows

    if "%triton_choice%"=="1" (
        echo Installing Triton Nightly
        %PYTHON% -s -m pip install -U --pre triton-windows
    ) else if "%triton_choice%"=="2" (
        echo Installing Triton Stable
        %PYTHON% -s -m pip install triton-windows
    ) else if "%triton_choice%"=="3" (
        echo Installing LeoMaxwell Triton
        %PYTHON% -s -m pip install https://github.com/leomaxwell973/Triton-3.3.0-UPDATE_FROM_3.2.0_and_FIXED-Windows-Nvidia-Prebuilt/releases/download/3.3.0_cu128_Py312/triton-3.3.0-cp312-cp312-win_amd64.whl
    )
)

if "%INSTALL_SAGE%"=="true" (
    echo [INFO] Uninstalling old SageAttention versions
    %PYTHON% -s -m pip uninstall -y sageattention

    if "%sage_choice%"=="1" (
        echo Installing SageAttention v1
        %PYTHON% -s -m pip install sageattention==1.0.6
    ) else (
        echo Installing SageAttention v2 from source
        cd "%UPDATE_DIR%"
        git clone https://github.com/thu-ml/SageAttention
        cd SageAttention
        set MAX_JOBS=%CPU_CORES%
        %PYTHON% -s -m pip install .

        cd ..
        rmdir /s /q SageAttention
    )
)


if "%UPDATE_COMFY%"=="true" (
    echo Updating ComfyUI
    pushd "%COMFY_DIR%"
    git pull
    popd
)

echo Installing ComfyUI Manager if not exists
cd /d "%COMFY_DIR%\custom_nodes"
if not exist ComfyUI-Manager (
    git clone https://github.com/ltdrdata/ComfyUI-Manager.git
)

cd /d "%UPDATE_DIR%"
%PYTHON% update.py ..\ComfyUI\
if exist update_new.py (
    move /y update_new.py update.py
    %PYTHON% update.py ..\ComfyUI\ --skip_self_update
)

if "%MAKE_LAUNCHER%"=="true" (
    echo Creating run_comfyui_fp16fast_sage.bat
    set "LAUNCHER=%ROOT%\ComfyUI_windows_portable\run_comfyui_fp16fast_sage.bat"
    (
    echo call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
    echo .\python_embeded\python.exe -s ComfyUI\main.py --use-sage-attention --windows-standalone-build --fast fp16_accumulation --listen 0.0.0.0
    echo pause
    ) > "%LAUNCHER%"
)

echo.
echo All selected components installed. You may now run ComfyUI.
pause
exit /b