File size: 2,714 Bytes
9758e85
 
6a879cf
9758e85
 
 
 
 
 
6a879cf
 
9758e85
 
 
 
6a879cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9758e85
 
 
 
 
 
 
 
 
 
6a879cf
 
 
 
 
9758e85
 
 
6a879cf
 
 
 
 
 
 
9758e85
 
 
6a879cf
9758e85
 
 
 
 
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
@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