Last active
October 30, 2025 15:25
-
-
Save sfinktah/85459b3a9bcf959d6c3ace7e777cb66e to your computer and use it in GitHub Desktop.
install native windows amd backend for comfyui
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| set PYTHON="%~dp0/venv/Scripts/python.exe" | |
| set VENV_DIR=./venv | |
| rem set PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.6,max_split_size_mb:512 | |
| set COMMANDLINE_ARGS=--reserve-vram 0.5 --use-pytorch-cross-attention %* | |
| :loop | |
| echo. | |
| %PYTHON% main.py %COMMANDLINE_ARGS% | |
| echo. | |
| rem check if we exited with an error | |
| if errorlevel 1 ( | |
| echo exited with error code %errorlevel% | |
| pause | |
| exit /b %errorlevel% | |
| ) | |
| echo Waiting 3 seconds before next run. Press any key to exit... | |
| timeout /t 3 /nobreak > nul | |
| if errorlevel 1 goto :eof | |
| goto loop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| setlocal ENABLEDELAYEDEXPANSION | |
| set PYTHON="%~dp0/venv/Scripts/python.exe" | |
| set VENV_DIR=./venv | |
| :: ComfyUI options for fun and profit: | |
| :: | |
| :: --use-pytorch-cross-attention | |
| :: --use-quad-cross-attention | |
| :: --use-flash-attention | |
| :: --use-sage-attention | |
| :: --use-pytorch-cross-attention | |
| :: | |
| :: --reserve-vram 0.9 | |
| :: --disable-smart-memory | |
| :: --lowvram | --normalvram | |
| :: | |
| :: set PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.6,max_split_size_mb:512 | |
| set COMMANDLINE_ARGS=%* | |
| :: This would be the **logical** place to put your ROCm files | |
| set HIP_PATH=C:\Program Files\AMD\ROCm\6.5\ | |
| set HIP_PATH_62= | |
| set HIP_PATH_65=%HIP_PATH% | |
| set CC=%HIP_PATH%bin\clang.exe | |
| set CXX=%HIP_PATH%bin\clang++.exe | |
| set CXXFLAGS=-march=native -mtune=native | |
| if not defined TRITON_OVERRIDE_ARCH set TRITON_OVERRIDE_ARCH=gfx1100 | |
| :: Example HIP_PATH (ensure it's set properly beforehand) | |
| :: set "HIP_PATH=C:\Program Files\AMD\ROCm" | |
| :: Normalize HIP_PATH to include trailing backslash if needed | |
| if not "%HIP_PATH:~-1%"=="\" set "HIP_PATH=%HIP_PATH%\" | |
| set "NEW_ENTRY=%HIP_PATH%bin" | |
| set "CLEANED_PATH=" | |
| :: Loop over PATH entries and exclude any that contain AMD\ROCm (case-insensitive) | |
| for %%P in ("%PATH:;=";"%") do ( | |
| set "PART=%%~P" | |
| echo !PART! | find /I "AMD\ROCm" >nul | |
| if errorlevel 1 ( | |
| if defined CLEANED_PATH ( | |
| set "CLEANED_PATH=!CLEANED_PATH!;!PART!" | |
| ) else ( | |
| set "CLEANED_PATH=!PART!" | |
| ) | |
| ) | |
| ) | |
| :: Now prepend NEW_ENTRY | |
| set "PATH=%NEW_ENTRY%;%CLEANED_PATH%" | |
| :: Confirm result | |
| echo Final PATH: | |
| echo %PATH% | |
| set MIOPEN_FIND_MODE=2 | |
| set MIOPEN_LOG_LEVEL=3 | |
| set MIOPEN_DEBUG_CONV_DIRECT_NAIVE_CONV_FWD=0 | |
| set FLASH_ATTENTION_TRITON_AMD_ENABLE=TRUE | |
| set FLASH_ATTENTION_TRITON_AMD_AUTOTUNE=TRUE | |
| :: Excessive debugging for Triton | |
| :: set TORCHDYNAMO_VERBOSE=1 | |
| :: set AMDGCN_ENABLE_DUMP=1 | |
| :: Things you could hypothetically set to make a different (set to default values) | |
| :: set TRITON_HIP_GLOBAL_PREFETCH=0 | |
| :: set TRITON_HIP_LOCAL_PREFETCH=0 | |
| :: set TRITON_HIP_USE_ASYNC_COPY=0 | |
| :: set TRITON_DEFAULT_FP_FUSION=1 | |
| :: These two are enabled for gfx942 | |
| :: set TRITON_HIP_USE_BLOCK_PINGPONG=0 | |
| :: set TRITON_HIP_USE_IN_THREAD_TRANSPOSE=0 | |
| :: Add directories to PATH for this session only, this is an extra step to make sure comfy or the torch's inside do not mistakenly use other hip stuff on your pc. Might not be needed but it is good to have here. | |
| echo %%%%%% ----------- %%%%%% | |
| echo %%%%%% Environment %%%%%% | |
| echo %%%%%% ----------- %%%%%% | |
| set HIP_PATH | |
| set HIP_PATH_65 | |
| set CC | |
| set CXX | |
| set TRITON_OVERRIDE_ARCH | |
| set MIOPEN_FIND_MODE | |
| set MIOPEN_LOG_LEVEL | |
| set FLASH_ATTENTION_TRITON_AMD_ENABLE | |
| set FLASH_ATTENTION_TRITON_AMD_AUTOTUNE | |
| set TORCHDYNAMO_VERBOSE | |
| echo %%%%%% ----------- %%%%%% | |
| where clang | |
| where clang++ | |
| echo %%%%%% ----------- %%%%%% | |
| echo %%%%%% ----------- %%%%%% | |
| :: remove the dots before git pull down below if you want comfy to auto update at each run. | |
| :: git pull | |
| :: pip install -U comfyui-frontend-package comfyui-workflow-templates av comfyui-embedded-docs --quiet | |
| echo. | |
| %PYTHON% main.py %COMMANDLINE_ARGS% | |
| if errorlevel 1 ( | |
| echo exited with error code %errorlevel% | |
| pause | |
| exit /b %errorlevel% | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| :: This is for running triton 3.4.0 on ZLUDA based installs, see https://github.com/patientx/ComfyUI-Zluda/issues/222 | |
| setlocal ENABLEDELAYEDEXPANSION | |
| set HIP_PATH=C:\Program Files\AMD\ROCm\6.5\ | |
| set HIP_PATH_62= | |
| set HIP_PATH_65=%HIP_PATH% | |
| set CC=%HIP_PATH%bin\clang.exe | |
| set CXX=%HIP_PATH%bin\clang++.exe | |
| set CXXFLAGS=-march=native -mtune=native | |
| :: Example HIP_PATH (ensure it's set properly beforehand) | |
| :: set "HIP_PATH=C:\Program Files\AMD\ROCm" | |
| :: Normalize HIP_PATH to include trailing backslash if needed | |
| if not "%HIP_PATH:~-1%"=="\" set "HIP_PATH=%HIP_PATH%\" | |
| set "NEW_ENTRY=%HIP_PATH%bin" | |
| set "CLEANED_PATH=" | |
| :: Loop over PATH entries and exclude any that contain AMD\ROCm (case-insensitive) | |
| for %%P in ("%PATH:;=";"%") do ( | |
| set "PART=%%~P" | |
| echo !PART! | find /I "AMD\ROCm" >nul | |
| if errorlevel 1 ( | |
| if defined CLEANED_PATH ( | |
| set "CLEANED_PATH=!CLEANED_PATH!;!PART!" | |
| ) else ( | |
| set "CLEANED_PATH=!PART!" | |
| ) | |
| ) | |
| ) | |
| :: Now prepend NEW_ENTRY | |
| set "PATH=%NEW_ENTRY%;%CLEANED_PATH%" | |
| :: Confirm result | |
| echo Final PATH: | |
| echo %PATH% | |
| if not defined TRITON_OVERRIDE_ARCH set TRITON_OVERRIDE_ARCH=gfx1100 | |
| set MIOPEN_FIND_MODE=2 | |
| set MIOPEN_LOG_LEVEL=3 | |
| set FLASH_ATTENTION_TRITON_AMD_ENABLE=TRUE | |
| set FLASH_ATTENTION_TRITON_AMD_AUTOTUNE=TRUE | |
| :: set TORCH_LOGS=recompiles | |
| set TORCH_LOGS= | |
| set TRITON_CACHE_DIR=%~dp0/.triton | |
| set MIOPEN_CACHE_DIR=%~dp0/.miopen | |
| :: Excessive debugging for Triton | |
| :: set TORCHDYNAMO_VERBOSE=1 | |
| :: Really excessive debugging for Triton | |
| :: set AMDGCN_ENABLE_DUMP=1 | |
| :: Things you could hypothetically set to make a different (set to default values) | |
| :: set TRITON_HIP_GLOBAL_PREFETCH=0 | |
| :: set TRITON_HIP_LOCAL_PREFETCH=0 | |
| :: set TRITON_HIP_USE_ASYNC_COPY=0 | |
| :: set TRITON_DEFAULT_FP_FUSION=1 | |
| :: These two are enabled for gfx942 | |
| :: set TRITON_HIP_USE_BLOCK_PINGPONG=0 | |
| :: set TRITON_HIP_USE_IN_THREAD_TRANSPOSE=0 | |
| set FLASH_ATTENTION_TRITON_AMD_ENABLE=TRUE | |
| set FLASH_ATTENTION_TRITON_AMD_AUTOTUNE=TRUE | |
| set MIOPEN_FIND_MODE=2 | |
| set MIOPEN_LOG_LEVEL=3 | |
| set PYTHON="%~dp0/venv/Scripts/python.exe" | |
| set GIT= | |
| set VENV_DIR=./venv | |
| set COMMANDLINE_ARGS=--use-sage-attention --normalvram --reserve-vram 0 | |
| set ZLUDA_COMGR_LOG_LEVEL=1 | |
| echo *** Checking and updating to new version if possible | |
| copy comfy\customzluda\zluda-default.py comfy\zluda.py /y >NUL | |
| git pull | |
| copy comfy\customzluda\zluda.py comfy\zluda.py /y >NUL | |
| echo. | |
| .\zluda\zluda.exe -- %PYTHON% main.py %COMMANDLINE_ARGS% | |
| pause |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| SETLOCAL ENABLEDELAYEDEXPANSION | |
| echo Cleaning up compiled Python files... | |
| REM Delete __pycache__ folders | |
| FOR /D /R %%F IN (__pycache__) DO ( | |
| rem echo Deleting folder: %%F | |
| rmdir /S /Q "%%F" >NUL 2>NUL | |
| ) | |
| REM Delete .pyc and .pyo files | |
| FOR /R %%F IN (*.pyc *.pyo) DO ( | |
| rem echo Deleting file: %%F | |
| del /F /Q "%%F" >NUL 2>NUL | |
| ) | |
| echo. | |
| echo Searching for requirements.txt files... | |
| FOR /D %%D IN (*) DO ( | |
| IF EXIST "%%D\requirements.txt" ( | |
| echo ---------------------------------------------------- | |
| echo Found: %%D\requirements.txt | |
| echo Installing requirements in: %%D | |
| pushd "%%D" | |
| pip install -r requirements.txt | |
| popd | |
| ) | |
| ) | |
| echo. | |
| echo All done. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo "Cleaning up compiled Python files..." | |
| # Delete __pycache__ folders | |
| find . -type d -name '__pycache__' -exec rm -rf {} + 2>/dev/null | |
| # Delete .pyc and .pyo files | |
| find . -type f \( -name '*.pyc' -o -name '*.pyo' \) -delete 2>/dev/null | |
| echo | |
| echo "Searching for requirements.txt files..." | |
| # Find requirements.txt in top-level subdirectories only | |
| for dir in */ ; do | |
| if [[ -f "$dir/requirements.txt" ]]; then | |
| echo "----------------------------------------------------" | |
| echo "Found: $dir/requirements.txt" | |
| echo "Installing requirements in: $dir" | |
| (cd "$dir" && pip install -r requirements.txt) | |
| fi | |
| done | |
| echo | |
| echo "All done." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| rem ---- | |
| rem -- Install comfyui by runing | |
| rem -- git clone https://github.com/comfyanonymous/ComfyUI <optional name if you don't want it to be ComfyUI obviously> | |
| rem -- Then run this Script (I keep it in the parent directory, but doesn't make any difference) | |
| rem -- NOTE: The paths to the wheels will probably change, but that's your problem :) | |
| rem ---- | |
| title ComfyUI-Rock Installer | |
| setlocal EnableDelayedExpansion | |
| set "startTime=%time: =0%" | |
| echo --------------------------------------------------------------- | |
| Echo * COMFYUI-ROCK INSTALL (pytorch 2.7, python 3.11 or 3.12) * | |
| echo --------------------------------------------------------------- | |
| echo. | |
| echo :: %time:~0,8% :: - Setting up the virtual enviroment | |
| 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 | |
| echo :: %time:~0,8% :: - Virtual enviroment activation | |
| Call "%VIRTUAL_ENV%\Scripts\activate.bat" | |
| echo :: %time:~0,8% :: - Updating the pip package | |
| python.exe -m pip install --upgrade pip --quiet | |
| echo. | |
| echo :: %time:~0,8% :: Beginning installation ... | |
| echo. | |
| echo :: %time:~0,8% :: - Installing required packages | |
| pip install -r requirements.txt --quiet | |
| rem echo :: %time:~0,8% :: - Installing onnxruntime (required by some nodes) | |
| rem pip install onnxruntime --quiet | |
| echo :: %time:~0,8% :: - Detecting Python version and installing appropriate triton package | |
| for /f "tokens=2 delims=." %%a in ('python -c "import sys; print(sys.version)"') do ( | |
| set "PY_MINOR=%%a" | |
| goto :version_detected | |
| ) | |
| :version_detected | |
| echo :: %time:~0,8% :: - Installing torch AMD | |
| pip uninstall torch torchvision torchaudio -y --quiet | |
| if "%PY_MINOR%"=="11" ( | |
| echo :: %time:~0,8% :: - Python 3.11 detected | |
| pip install ^ | |
| https://github.com/scottt/rocm-TheRock/releases/download/v6.5.0rc-pytorch-gfx110x/torch-2.7.0a0+rocm_git3f903c3-cp311-cp311-win_amd64.whl ^ | |
| https://github.com/scottt/rocm-TheRock/releases/download/v6.5.0rc-pytorch-gfx110x/torchaudio-2.7.0a0+52638ef-cp311-cp311-win_amd64.whl ^ | |
| https://github.com/scottt/rocm-TheRock/releases/download/v6.5.0rc-pytorch-gfx110x/torchvision-0.22.0+9eb57cd-cp311-cp311-win_amd64.whl | |
| ) else if "%PY_MINOR%"=="12" ( | |
| echo :: %time:~0,8% :: - Python 3.12 detected | |
| pip install ^ | |
| https://github.com/scottt/rocm-TheRock/releases/download/v6.5.0rc-pytorch-gfx110x/torch-2.7.0a0+git3f903c3-cp312-cp312-win_amd64.whl ^ | |
| https://github.com/scottt/rocm-TheRock/releases/download/v6.5.0rc-pytorch-gfx110x/torchaudio-2.6.0a0+1a8f621-cp312-cp312-win_amd64.whl ^ | |
| https://github.com/scottt/rocm-TheRock/releases/download/v6.5.0rc-pytorch-gfx110x/torchvision-0.22.0+9eb57cd-cp312-cp312-win_amd64.whl | |
| ) else ( | |
| echo :: %time:~0,8% :: - WARNING: Unsupported Python version 3.%PY_MINOR%, skipping triton installation | |
| echo :: %time:~0,8% :: - Full version string: | |
| python -c "import sys; print(sys.version)" | |
| ) | |
| echo. | |
| echo :: %time:~0,8% :: - Installing Comfyui Manager | |
| cd custom_nodes | |
| git clone https://github.com/ltdrdata/ComfyUI-Manager.git --quiet | |
| echo :: %time:~0,8% :: - Installing ComfyUI-deepcache | |
| git clone https://github.com/styler00dollar/ComfyUI-deepcache.git --quiet | |
| git clone --branch sfink-opacity https://github.com/sfinktah/ComfyUI-TextOverlay.git --quiet | |
| cd .. | |
| echo. | |
| echo :: %time:~0,8% :: - Done | |
| echo. | |
| 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 ..................................................... | |
| echo. | |
| echo. | |
| python main.py --auto-launch --use-pytorch-cross-attention |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| if "%1"=="" ( | |
| echo Please provide the parent path as an argument | |
| echo Example: link.bat C:\zluda\comfyui-zluda | |
| exit /b 1 | |
| ) | |
| rmdir /S /Q models 2>nul | |
| rmdir /S /Q input 2>nul | |
| rmdir /S /Q output 2>nul | |
| rmdir /S /Q user 2>nul | |
| mklink /J "models" "%1\models" | |
| mklink /J "input" "%1\input" | |
| mklink /J "output" "%1\output" | |
| mklink /J "user" "%1\user" |
Author
--use-pytorch-cross-attention is the same as not specifying any attention at all. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exscuse me, in the README you state "Dont mess with --attention because aotriton is baked in." but then again in these scripts the startup args include "--use-pytorch-cross-attention". Is that ok?