Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
a5fbf7a
Draft (untested) install-n.bat
sfinktah Jul 28, 2025
23f29d9
Oops, can't use %2B in batch files unless you escape it. Replaced it…
sfinktah Aug 3, 2025
bb39d72
Double oops, can't use | without escaping it either.
sfinktah Aug 3, 2025
406fa7a
Need to go into utf mode to display line graphics? wtf
sfinktah Aug 3, 2025
da402e9
So, yeah. Test before commiting. New concept.
sfinktah Aug 3, 2025
1064a79
So, yeah. Test before commiting. New concept.
sfinktah Aug 3, 2025
bcf6578
Aligning box in ASCII intro. Annoyance.
sfinktah Aug 3, 2025
7cb0b23
Put the spaces in the wrong place.
sfinktah Aug 3, 2025
6093fac
Added a warning to set TRITON_OVERRIDE_ARCH in comfyui-n.bat
sfinktah Aug 3, 2025
8c4d655
Merge branch 'master' into sfink-install-n-torch2.8-triton
sfinktah Aug 15, 2025
2a4af6a
Changed sageattention patch to my latest automatic GPU detecting opti…
sfinktah Aug 15, 2025
fddce8f
torch 2.7.1
sfinktah Aug 18, 2025
1bb4ce9
fixed torch 2.8.0 link
sfinktah Aug 18, 2025
cb94769
fixed torch 2.8.0 link by reverting it to 2.7.0 link
sfinktah Aug 18, 2025
5b1fc2a
Updated ANSI banner to reflect PyTorch 2.7.0
sfinktah Aug 18, 2025
dbdfa98
Updated ANSI banner to reflect PyTorch 2.7.0
sfinktah Aug 18, 2025
6290fa0
**go** for hip 6.4 sdk
sfinktah Aug 19, 2025
2eab76b
Revert "**go** for hip 6.4 sdk"
sfinktah Aug 19, 2025
237d735
stay clean with 2.7
sfinktah Aug 19, 2025
29a0dba
**go** for hip 6.4 sdk
sfinktah Aug 19, 2025
1e2ef62
first draft of install-n.bat
sfinktah Aug 19, 2025
620d3a9
second draft of install-n.bat
sfinktah Aug 19, 2025
fd33c81
third draft of install-n.bat
sfinktah Aug 19, 2025
13bfaa2
fourth draft of install-n.bat
sfinktah Aug 19, 2025
e2e2960
fifth draft of install-n.bat
sfinktah Aug 19, 2025
92269ce
sixth draft of install-n.bat (added yaml for benlann)
sfinktah Aug 20, 2025
c7059c5
seventh draft of install-n.bat (made stuff --quiet)
sfinktah Aug 20, 2025
30c63ed
eighth draft of install-n.bat (multigpu detection)
sfinktah Aug 20, 2025
f81235a
eighth draft of install-n.bat (multigpu detection)
sfinktah Aug 20, 2025
31f0bf2
remove torch, torchaudio and torchvision entirely from requirements.txt
sfinktah Aug 20, 2025
6cfc648
double installing torchvision and torchaudio and pray user never inst…
sfinktah Aug 20, 2025
76a4405
added pytorch-2.8 patch for forcing max_autotune_gemm
sfinktah Aug 20, 2025
be8aff0
download pytorch 2.8 from my servers because versioning is fucked oth…
sfinktah Aug 20, 2025
ed7b9f3
added force-reinstall to torch, etc.
sfinktah Aug 20, 2025
cb5992c
install all 3 torch packages at once, silly.
sfinktah Aug 20, 2025
23c8924
Change multi-gpu DETECTION to look for higher card, stopped patching …
sfinktah Aug 20, 2025
67da4b6
**go** for hip 6.4 sdk
sfinktah Aug 19, 2025
1ddc736
first draft of install-n.bat
sfinktah Aug 19, 2025
74c0d05
second draft of install-n.bat
sfinktah Aug 19, 2025
5ada780
third draft of install-n.bat
sfinktah Aug 19, 2025
d464edf
fourth draft of install-n.bat
sfinktah Aug 19, 2025
5f2e709
fifth draft of install-n.bat
sfinktah Aug 19, 2025
781ce1d
sixth draft of install-n.bat (added yaml for benlann)
sfinktah Aug 20, 2025
e9058fd
seventh draft of install-n.bat (made stuff --quiet)
sfinktah Aug 20, 2025
d9352d5
eighth draft of install-n.bat (multigpu detection)
sfinktah Aug 20, 2025
9787be3
eighth draft of install-n.bat (multigpu detection)
sfinktah Aug 20, 2025
5357ac4
remove torch, torchaudio and torchvision entirely from requirements.txt
sfinktah Aug 20, 2025
e83d2d4
double installing torchvision and torchaudio and pray user never inst…
sfinktah Aug 20, 2025
f0d7c4a
added pytorch-2.8 patch for forcing max_autotune_gemm
sfinktah Aug 20, 2025
21016a5
download pytorch 2.8 from my servers because versioning is fucked oth…
sfinktah Aug 20, 2025
c9b5790
added force-reinstall to torch, etc.
sfinktah Aug 20, 2025
794ec26
install all 3 torch packages at once, silly.
sfinktah Aug 20, 2025
f02e993
Change multi-gpu DETECTION to look for higher card, stopped patching …
sfinktah Aug 20, 2025
bd6bffa
just some crap
sfinktah Aug 22, 2025
f00fd4e
Merge remote-tracking branch 'origin/sfink-hip64' into sfink-hip64
sfinktah Aug 22, 2025
980df3e
Merge branch 'sfink-hip64' into sfink-install-n-torch2.8-triton
sfinktah Aug 22, 2025
cc79380
restored it to what it was originally
sfinktah Aug 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
255 changes: 255 additions & 0 deletions INSTALL_PSEUDOCODE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
ComfyUI-Zluda Installer — Pseudo-code (grouped by related packages and subsystems)
NOTE: This document has been reorganized and rewritten for clarity. Please prefer reading INSTALL_PSEUDOCODE_REWRITTEN.txt.

A. Console and global GPU/SDK configuration
- Set console to UTF-8 and set window title.
- Define HIP SDK location (e.g., HIP_SDK_DIR = "C:\Program Files\AMD\ROCm\6.5").
- Enable ZLUDA COMGR logging (ZLUDA_COMGR_LOG_LEVEL = 1).
- Record start timestamp for elapsed-time reporting.
Addendum: Original commands
- @echo off
- chcp 65001 >nul
- title ComfyUI-Zluda Installer
- set HIP_SDK_DIR=C:\Program Files\AMD\ROCm\6.5
- set ZLUDA_COMGR_LOG_LEVEL=1
- set ESC=
- setlocal EnableDelayedExpansion
- set "startTime=%time: =0%"
- cls
- pause

B. Python virtual environment setup
- Define VIRTUAL_ENV = "venv".
- If venv activation script does not exist:
- Create venv with "python -m venv venv".
- If activation script still missing, exit with error.
- Activate the virtual environment.
- Upgrade pip to the latest version.
- Package: pip
Addendum: Original commands
- Set "VIRTUAL_ENV=venv"
- If Not Exist "%VIRTUAL_ENV%\Scripts\activate.bat" (
python.exe -m venv %VIRTUAL_ENV%
)
- If Not Exist "%VIRTUAL_ENV%\Scripts\activate.bat" Exit /B 1
- Call "%VIRTUAL_ENV%\Scripts\activate.bat"
- python.exe -m pip install --upgrade pip --quiet

C. PyTorch stack installation (torch/torchvision/torchaudio + core deps)
- Two alternatives are provided (choose one), then:
- Always perform C.3 (Torch DLL patching) after installing either alternative.
- Perform C.4 (Torch code patch) only if you installed Torch 2.7.x in C.2.

C.1 Nightly torch (pre-release) for CUDA 11.8
- URL: https://download.pytorch.org/whl/nightly/cu118
- Command: pip install --force-reinstall --pre torch --index-url https://download.pytorch.org/whl/nightly/cu118
- Command: pip install --force-reinstall --pre torchaudio torchvision --index-url https://download.pytorch.org/whl/nightly/cu118 --no-deps
- Command: pip install numpy==1.* pillow torch
- Package: torch
- Package: torchaudio
- Package: torchvision
- Package: numpy==1.*
- Package: pillow

C.2 Stable pinned Torch 2.7.x for CUDA 11.8
- URL: https://download.pytorch.org/whl/cu118
- Command: pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0 --index-url https://download.pytorch.org/whl/cu118 --quiet
- Package: torch==2.7.0
- Package: torchvision==0.22.0
- Package: torchaudio==2.7.0

C.3 Torch DLL patching with ZLUDA shims
- Applies to both C.1 (Nightly) and C.2 (Stable 2.7.x).
- Replace Torch’s CUDA DLLs with ZLUDA-provided shims to match Torch’s expected library names.
- Map: cublas -> cublas64_11.dll, cusparse -> cusparse64_11.dll, cudnn -> cudnn64_9.dll, cufft -> cufft64_10.dll, cufftw -> cufftw64_10.dll.
- Adjust NVRTC DLLs: duplicate existing nvrtc64_112_0.dll to nvrtc_cuda.dll, then overwrite nvrtc64_112_0.dll with ZLUDA nvrtc.dll.
- Note: ZLUDA files are sourced from the local 'zluda' folder downloaded in Step K.

C.4 Torch code patch (only when using Torch 2.7.x)
- Applies only if you installed Torch 2.7.x in C.2.
- Apply Torch 2.7.0 patch to improve compatibility.
- URL: https://raw.githubusercontent.com/sfinktah/amd-torch/refs/heads/main/patches/torch-2.7.0+cu118-cp311-cp311-win_amd64.patch
- Command: pypatch-url apply https://raw.githubusercontent.com/sfinktah/amd-torch/refs/heads/main/patches/torch-2.7.0+cu118-cp311-cp311-win_amd64.patch -p 4 torch

- Note: The sequence ensures torch presence; dependency resolver warnings are expected for the nightly step.
Addendum: Original commands
- pip install --force-reinstall --pre torch --index-url https://download.pytorch.org/whl/nightly/cu118
- pip install --force-reinstall --pre torchaudio torchvision --index-url https://download.pytorch.org/whl/nightly/cu118 --no-deps
- pip install numpy==1.* pillow torch
- pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0 --index-url https://download.pytorch.org/whl/cu118 --quiet
- copy zluda\cublas.dll %VIRTUAL_ENV%\Lib\site-packages\torch\lib\cublas64_11.dll /y >NUL
- copy zluda\cusparse.dll %VIRTUAL_ENV%\Lib\site-packages\torch\lib\cusparse64_11.dll /y >NUL
- copy %VIRTUAL_ENV%\Lib\site-packages\torch\lib\nvrtc64_112_0.dll %VIRTUAL_ENV%\Lib\site-packages\torch\lib\nvrtc_cuda.dll /y >NUL
- copy zluda\nvrtc.dll %VIRTUAL_ENV%\Lib\site-packages\torch\lib\nvrtc64_112_0.dll /y >NUL
- copy zluda\cudnn.dll %VIRTUAL_ENV%\Lib\site-packages\torch\lib\cudnn64_9.dll /y >NUL
- copy zluda\cufft.dll %VIRTUAL_ENV%\Lib\site-packages\torch\lib\cufft64_10.dll /y >NUL
- copy zluda\cufftw.dll %VIRTUAL_ENV%\Lib\site-packages\torch\lib\cufftw64_10.dll /y >NUL
- pypatch-url apply https://raw.githubusercontent.com/sfinktah/amd-torch/refs/heads/main/patches/torch-2.7.0+cu118-cp311-cp311-win_amd64.patch -p 4 torch

D. General Python dependencies
- Install project requirements from requirements.txt.
- Install onnxruntime (needed by some nodes).
- Apply temporary numpy fix by force-reinstalling numpy==1.*.
- Package: onnxruntime
- Package: numpy==1.*
Addendum: Original commands
- pip install -r requirements.txt --quiet
- pip install onnxruntime --quiet
- pip install --force-reinstall numpy==1.*

E. Triton installation (version selected by Python minor version)
- Detect Python minor version (PY_MINOR).
- Two alternatives are provided (choose the one matching your Python):

E.1 Python 3.12 (cp312 wheel)
- URL: https://github.com/lshqqytiger/triton/releases/download/a9c80202/triton-3.4.0+gita9c80202-cp312-cp312-win_amd64.whl
- Command: pip install --force-reinstall https://github.com/lshqqytiger/triton/releases/download/a9c80202/triton-3.4.0+gita9c80202-cp312-cp312-win_amd64.whl
- Package: triton

E.2 Python 3.11 (cp311 wheel)
- URL: https://github.com/lshqqytiger/triton/releases/download/a9c80202/triton-3.4.0+gita9c80202-cp311-cp311-win_amd64.whl
- Command: pip install --force-reinstall https://github.com/lshqqytiger/triton/releases/download/a9c80202/triton-3.4.0+gita9c80202-cp311-cp311-win_amd64.whl
- Package: triton

E.3 Triton patch (post-install)
- URL: https://raw.githubusercontent.com/sfinktah/amd-torch/refs/heads/main/patches/triton-3.4.0+gita9c80202-cp311-cp311-win_amd64.patch
- Command: pypatch-url apply https://raw.githubusercontent.com/sfinktah/amd-torch/refs/heads/main/patches/triton-3.4.0+gita9c80202-cp311-cp311-win_amd64.patch -p 4 triton

- Else:
- Warn about unsupported Python minor version and print full version string.
- Note: Uses --force-reinstall for explicit wheel installs.
Addendum: Original commands
- for /f "tokens=2 delims=." %%a in ('python -c "import sys; print(sys.version)"') do (
set "PY_MINOR=%%a"
goto :version_detected
)
- :version_detected
- if "%PY_MINOR%"=="12" (
pip install --force-reinstall https://github.com/lshqqytiger/triton/releases/download/a9c80202/triton-3.4.0+gita9c80202-cp312-cp312-win_amd64.whl
) else if "%PY_MINOR%"=="11" (
pip install --force-reinstall https://github.com/lshqqytiger/triton/releases/download/a9c80202/triton-3.4.0+gita9c80202-cp311-cp311-win_amd64.whl
) else (
echo :: - WARNING: Unsupported Python version 3.%PY_MINOR%, skipping triton installation
echo :: - Full version string:
python -c "import sys; print(sys.version)"
)
- pypatch-url apply https://raw.githubusercontent.com/sfinktah/amd-torch/refs/heads/main/patches/triton-3.4.0+gita9c80202-cp311-cp311-win_amd64.patch -p 4 triton

F. Patching and performance libraries
- Install pypatch-url tool to apply patches.
- Command: pip install --force-reinstall pypatch-url --quiet
- Package: pypatch-url
- Note: Uses --force-reinstall.
Addendum: Original commands
- pip install --force-reinstall pypatch-url --quiet

G. Flash Attention 2 setup
- Obtain and install a wheel extracted from a downloaded archive:
1) Download the ZIP archive containing the wheel.
- URL: https://github.com/user-attachments/files/20140536/flash_attn-2.7.4.post1-py3-none-any.zip
2) Extract the ZIP to produce flash_attn-2.7.4.post1-py3-none-any.whl.
3) Install the extracted wheel.
- Command: pip install flash_attn-2.7.4.post1-py3-none-any.whl --quiet
4) Clean up by removing the downloaded ZIP and the extracted wheel.
- Replace flash_attn’s distributed.py inside site-packages with a project-provided compatibility file:
- Source file: comfy\customzluda\fa\distributed.py
- Target path: %VIRTUAL_ENV%\Lib\site-packages\flash_attn\utils\distributed.py
- Command: copy comfy\customzluda\fa\distributed.py %VIRTUAL_ENV%\Lib\site-packages\flash_attn\utils\distributed.py /y
- Package: flash_attn-2.7.4.post1-py3-none-any.whl
- Package: flash_attn
Addendum: Original commands
- %SystemRoot%\system32\curl.exe -sL --ssl-no-revoke https://github.com/user-attachments/files/20140536/flash_attn-2.7.4.post1-py3-none-any.zip > fa.zip
- %SystemRoot%\system32\tar.exe -xf fa.zip
- pip install flash_attn-2.7.4.post1-py3-none-any.whl --quiet
- del fa.zip
- del flash_attn-2.7.4.post1-py3-none-any.whl
- copy comfy\customzluda\fa\distributed.py %VIRTUAL_ENV%\Lib\site-packages\flash_attn\utils\distributed.py /y >NUL

H. Sage Attention setup
- Install sageattention and braceexpand (and ensure pypatch-url present).
- Apply patch to sageattention for environment compatibility.
- Package: pypatch-url
- Package: sageattention
- Package: braceexpand
- URL: https://raw.githubusercontent.com/sfinktah/amd-torch/refs/heads/main/patches/sageattention-1.0.6+sfinktah+env-py3-none-any.patch
Addendum: Original commands
- pip install --force-reinstall pypatch-url sageattention braceexpand --quiet
- pypatch-url apply https://raw.githubusercontent.com/sfinktah/amd-torch/refs/heads/main/patches/sageattention-1.0.6+sfinktah+env-py3-none-any.patch -p 4 sageattention

I. Custom nodes for ComfyUI
- Copy CFZ helper scripts into custom_nodes (patcher, cudnn toggle, VAE loader).
- In custom_nodes folder:
- Clone ComfyUI-Manager.
- Clone ComfyUI-deepcache.
- Return to repository root.
- URL: https://github.com/ltdrdata/ComfyUI-Manager.git
- URL: https://github.com/styler00dollar/ComfyUI-deepcache.git
Addendum: Original commands
- copy cfz\cfz_patcher.py custom_nodes\cfz_patcher.py /y >NUL
- copy cfz\cfz_cudnn.toggle.py custom_nodes\cfz_cudnn.toggle.py /y >NUL
- copy cfz\cfz_vae_loader.py custom_nodes\cfz_vae_loader.py /y >NUL
- cd custom_nodes
- git clone https://github.com/ltdrdata/ComfyUI-Manager.git --quiet
- git clone https://github.com/styler00dollar/ComfyUI-deepcache.git --quiet
- cd ..

J. CPython runtime libs placement (for extension loading compatibility)
- Copy CPython "libs" directory for detected Python minor version into "venv\libs".
- If the copy fails, exit with error.
Addendum: Original commands
- xcopy /E /I /Y "%LocalAppData%\Programs\Python\Python3%PY_MINOR%\libs" "venv\libs"
- set ERRLEVEL=%errorlevel%
- if %ERRLEVEL% neq 0 (
echo "Failed to copy Python3%PY_MINOR%\libs to virtual environment."
exit /b %ERRLEVEL%
)

K. ZLUDA setup
- Remove existing "zluda" folder if present; create a new one.
- Download ZLUDA nightly ROCm6 Windows build and extract into "zluda".
- Copy customized zluda.py into project (used to integrate ZLUDA behavior).
- URL: https://github.com/lshqqytiger/ZLUDA/releases/download/rel.5e717459179dc272b7d7d23391f0fad66c7459cf/ZLUDA-nightly-windows-rocm6-amd64.zip
Addendum: Original commands
- rmdir /S /Q zluda 2>nul
- mkdir zluda
- cd zluda
- %SystemRoot%\system32\curl.exe -sL --ssl-no-revoke https://github.com/lshqqytiger/ZLUDA/releases/download/rel.5e717459179dc272b7d7d23391f0fad66c7459cf/ZLUDA-nightly-windows-rocm6-amd64.zip > zluda.zip
- %SystemRoot%\system32\tar.exe -xf zluda.zip
- del zluda.zip
- cd ..
- copy comfy\customzluda\zluda.py comfy\zluda.py /y >NUL

L. Elapsed time reporting and guidance
- Compute and display the total installation time.
- Provide usage notes:
- Start later via comfyui-n.bat.
- Consider copying comfyui-n.bat to customize flags without affecting updates.
- Supported attention flags: --use-pytorch-cross-attention, --use-quad-cross-attention, --use-flash-attention, --use-sage-attention.
Addendum: Original commands
- set "endTime=%time: =0%"
- set "end=!endTime:%time:~8,1%=%%100)*100+1!" & set "start=!startTime:%time:~8,1%=%%100)*100+1!"
- set /A "elap=((((10!end:%time:~2,1%=%%100)*60+1!%%100)-((((10!start:%time:~2,1%=%%100)*60+1!%%100), elap-=(elap>>31)*24*60*60*100"
- set /A "cc=elap%%100+100,elap/=100,ss=elap%%60+100,elap/=60,mm=elap%%60+100,hh=elap/60+100"
- echo .....................................................
- echo *** Installation is completed in %hh:~1%%time:~2,1%%mm:~1%%time:~2,1%%ss:~1%%time:~8,1%%cc:~1% .
- echo *** You can use "comfyui-n.bat" to start the app later.
- echo *** It is advised to make a copy of "comfyui-n.bat" and modify it to your liking so when updating later it won't cause problems.
- echo *** You can use -- "--use-pytorch-cross-attention" , "--use-quad-cross-attention" , "--use-flash-attention" or "--use-sage-attention"
- echo .....................................................
- echo.

M. Launch configuration and first run
- Set GPU-related environment variables prior to launch:
- FLASH_ATTENTION_TRITON_AMD_ENABLE=TRUE
- MIOPEN_FIND_MODE=2
- MIOPEN_LOG_LEVEL=3
- Launch ComfyUI via ZLUDA layer:
- Execute zluda.exe to run: python main.py --auto-launch --use-sage-attention
- Inform the user that the first start may take some time.
Addendum: Original commands
- echo *** Starting the Comfyui-ZLUDA for the first time, please be patient...
- echo.
- set FLASH_ATTENTION_TRITON_AMD_ENABLE=TRUE
- set MIOPEN_FIND_MODE=2
- set MIOPEN_LOG_LEVEL=3
- .\zluda\zluda.exe -- python main.py --auto-launch --use-sage-attention
Loading