| @ECHO OFF | |
| CALL environment.bat passive | |
| ECHO # SageAttention2 install script | |
| ECHO. | |
| ECHO This will install Triton and SageAttention 2.2.0 into the Python environment. | |
| ECHO An Internet connection is required to download the necessary components. | |
| PAUSE | |
| set SAGEATTN_CU128_WHL=https://github.com/woct0rdho/SageAttention/releases/download/v2.2.0-windows.post4/sageattention-2.2.0+cu128torch2.9.0andhigher.post4-cp39-abi3-win_amd64.whl | |
| set SAGEATTN_CU130_WHL=https://github.com/woct0rdho/SageAttention/releases/download/v2.2.0-windows.post4/sageattention-2.2.0+cu130torch2.9.0andhigher.post4-cp39-abi3-win_amd64.whl | |
| set PYTHONUTF8=1 | |
| set PYTHONIOENCODING=utf-8 | |
| set PYTHON=python_embeded\python.exe | |
| for /f "tokens=1,2" %%A in ('%PYTHON% -s -m pip list') do ( | |
| if "%%A"=="torch" ( | |
| set TORCH_VERSION=%%B | |
| ) | |
| ) | |
| if not defined TORCH_VERSION ( | |
| ECHO ERROR: PyTorch is not installed in this Python environment. | |
| ECHO Aborting. | |
| PAUSE | |
| EXIT /B 1 | |
| ) | |
| echo %TORCH_VERSION% | findstr /i "+cu128" >nul | |
| if %errorlevel%==0 ( | |
| set TORCH_CUDA=cu128 | |
| set SAGEATTN_WHL=%SAGEATTN_CU128_WHL% | |
| goto :cuda_ok | |
| ) | |
| echo %TORCH_VERSION% | findstr /i "+cu130" >nul | |
| if %errorlevel%==0 ( | |
| set TORCH_CUDA=cu130 | |
| set SAGEATTN_WHL=%SAGEATTN_CU130_WHL% | |
| goto :cuda_ok | |
| ) | |
| ECHO. | |
| ECHO ERROR: Unsupported CUDA build detected. | |
| ECHO Torch reports: %TORCH_VERSION% | |
| ECHO Supported builds: cu128 or cu130 only. | |
| ECHO Aborting before installation. | |
| PAUSE | |
| EXIT /B 1 | |
| :cuda_ok | |
| ECHO. | |
| ECHO CUDA build detected: %TORCH_CUDA% | |
| ECHO Using SageAttention package: %SAGEATTN_WHL% | |
| ECHO. | |
| ECHO ### Installing Visual Studio Build Tools. | |
| ECHO If you already have a compatible version, the update will read "Installer failed with exit code: 1". This is normal! | |
| ECHO ==================================================================================================================== | |
| winget install --id Microsoft.VisualStudio.2022.BuildTools -e --source winget --override "--quiet --wait --norestart --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.20348" | |
| ECHO. | |
| ECHO ### Installing Triton | |
| ECHO ===================== | |
| %PYTHON% -s -m pip install triton-windows | |
| if errorlevel 1 ( | |
| ECHO ERROR: Triton installation failed. | |
| PAUSE | |
| EXIT /B 1 | |
| ) | |
| ECHO. | |
| ECHO ### Installing SageAttention | |
| ECHO ============================ | |
| %PYTHON% -s -m pip install %SAGEATTN_WHL% | |
| if errorlevel 1 ( | |
| ECHO ERROR: SageAttention installation failed. | |
| PAUSE | |
| EXIT /B 1 | |
| ) | |
| ECHO Runnning test script ... | |
| ECHO. | |
| %PYTHON% .\python_embeded\test_sageattn.py | |
| ECHO. | |
| ECHO Installation complete ... | |
| ECHO. | |
| pause |