StabilityMatrix
StabilityMatrix copied to clipboard
Triton 3 wheels published for Windows
Proposal
As seen here https://www.reddit.com/r/StableDiffusion/comments/1g45n6n/triton_3_wheels_published_for_windows_and_working/
Comfy could get a 24% speed benefit, should we try the pull or not? Thank you.
It seems the Python installed by StabilityMatrix is an incomplete installation, and it lacks distutils. Please ask the authors of StabilityMatrix to fix that.
btw why stablitymatrix replace venv created with python 3.11. i want to use existing venv when using with stablity matrix.
This issue is stale because it has been open 30 days with no activity. Remove the stale label or comment, else this will be closed in 5 days.
This is becoming a problem with many of the new video generaiton models requiring triton and sage. It would be great to be able to leverage the comfyUI in stable diffusion.
I think those issues are related: #954 and #801 I use StabilityMatrix for 2 years and don't want to drop 🥹 Also found this issue from Reddit thread (see below): https://www.reddit.com/r/StableDiffusion/comments/1iz8npm/comment/mf1uran/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
Q: Is there any roadmap on updated/compatible Python version?
There's nothing stopping you from installing pre-built wheels from the link above. Download the Python 3.10 version, open the Python Packages dialog, click the + button, and enter the path to the file you downloaded:
Congrats, Triton is now installed in whichever webUI you chose.
Q: Is there any roadmap on updated/compatible Python version?
We are working on it. It's not as easy as it seems.
There's nothing stopping you from installing pre-built wheels from the link above. Download the Python 3.10 version, open the Python Packages dialog, click the
+button, and enter the path to the file you downloaded:
Congrats, Triton is now installed in whichever webUI you chose.
Q: Is there any roadmap on updated/compatible Python version?
We are working on it. It's not as easy as it seems.
ITS INSTALL BUT NOT WORK, NOT A ISSUE WITH NORMAL VENV
PS S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI> venv\Scripts\activate
(venv) PS S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI> pip install triton-3.2.0-cp310-cp310-win_amd64.whl
Processing s:\ai\visual\stabilitymatrix\data\packages\comfyui webui\triton-3.2.0-cp310-cp310-win_amd64.whl
Installing collected packages: triton
Attempting uninstall: triton
Found existing installation: triton 3.1.0
Uninstalling triton-3.1.0:
Successfully uninstalled triton-3.1.0
Successfully installed triton-3.2.0
(venv) PS S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI> ./test.py
(venv) PS S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI> python test.py
Traceback (most recent call last):
File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\test.py", line 2, in
There's nothing stopping you from installing pre-built wheels from the link above. Download the Python 3.10 version, open the Python Packages dialog, click the
+button, and enter the path to the file you downloaded:Congrats, Triton is now installed in whichever webUI you chose.
Q: Is there any roadmap on updated/compatible Python version?
We are working on it. It's not as easy as it seems.
ITS INSTALL BUT NOT WORK, NOT A ISSUE WITH NORMAL VENV
PS S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI> venv\Scripts\activate (venv) PS S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI> pip install triton-3.2.0-cp310-cp310-win_amd64.whl Processing s:\ai\visual\stabilitymatrix\data\packages\comfyui webui\triton-3.2.0-cp310-cp310-win_amd64.whl Installing collected packages: triton Attempting uninstall: triton Found existing installation: triton 3.1.0 Uninstalling triton-3.1.0: Successfully uninstalled triton-3.1.0 Successfully installed triton-3.2.0 (venv) PS S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI> ./test.py (venv) PS S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI> python test.py Traceback (most recent call last): File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\test.py", line 2, in import triton File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages\triton__init__.py", line 20, in from .runtime import ( File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages\triton\runtime__init__.py", line 1, in from .autotuner import (Autotuner, Config, Heuristics, autotune, heuristics) File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages\triton\runtime\autotuner.py", line 9, in from .jit import KernelInterface File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages\triton\runtime\jit.py", line 12, in from ..runtime.driver import driver File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages\triton\runtime\driver.py", line 1, in from ..backends import backends File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages\triton\backends__init__.py", line 50, in backends = discover_backends() File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages\triton\backends__init_.py", line 44, in discover_backends driver = load_module(name, os.path.join(root, name, 'driver.py')) File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages\triton\backends__init.py", line 12, in load_module spec.loader.exec_module(module) File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages\triton\backends\amd\driver.py", line 7, in from triton.runtime.build import build File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages\triton\runtime\build.py", line 8, in import setuptools File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages\setuptools__init.py", line 22, in import distutils_hack.override # noqa: F401 File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages_distutils_hack\override.py", line 1, in import('distutils_hack').do_override() File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages_distutils_hack__init.py", line 89, in do_override ensure_local_distutils() File "S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\lib\site-packages_distutils_hack__init__.py", line 76, in ensure_local_distutils assert '_distutils' in core.file, core.file AssertionError: S:\Ai\Visual\StabilityMatrix\Data\Packages\ComfyUI WebUI\venv\Scripts\python310.zip\distutils\core.pyc
There's no need to yell. If you want it done, the code is open source, feel free to submit a PR.
I've been using StabilityMatrix for a long time, but I guess the only way to have Triton actually working is to drop it and switch to ComfyUI portable, then ?
I've been using StabilityMatrix for a long time, but I guess the only way to have Triton actually working is to drop it and switch to ComfyUI portable, then ?
the only way, i think.
A member of our Discord has written a guide to get it working in SM's Comfy, I'll paste it here. Many thanks to Xaragan on our Discord!
Installing SageAttention on StabilityMatrix (Windows)
This guide provides a step-by-step process to install SageAttention 2.1.1 for ComfyUI in StabilityMatrix on Windows 11.
1. Prerequisites: Ensure Required Dependencies Are Installed
Before proceeding, make sure the following are installed and properly configured:
✅ Python 3.10 (required by StabilityMatrix)
- Stability Matrix only supports Python 3.10 as of February 28, 2025.
✅ Visual Studio 2022 Build Tools
- Required for compiling components
✅ CUDA 12.8 (Global Installation)
- NOT within ComfyUI but as a system-wide installation
- Install from: https://developer.nvidia.com/cuda-downloads
- Verify CUDA 12.8 is set as default:
nvcc --version - If an older CUDA version is shown, update your environment variables:
set PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\bin;%PATH% set CUDA_HOME=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8
2. Set Up the Environment
-
Open Command Prompt (
cmd.exe) as Administrator -
Navigate to your StabilityMatrix ComfyUI installation folder:
cd /d [YOUR_STABILITY_MATRIX_PATH]\Data\Packages\ComfyUIReplace
[YOUR_STABILITY_MATRIX_PATH]with your actual installation path (e.g.,D:\Stability_Matrix) -
Activate the virtual environment:
call venv\Scripts\activate.bat
3. Fix Distutils and Setuptools Issues
StabilityMatrix's embedded Python lacks some standard components that need to be fixed:
-
Set the required environment variable:
set SETUPTOOLS_USE_DISTUTILS=stdlib -
Upgrade setuptools:
pip install --upgrade setuptools
4. Install Triton Manually
SageAttention requires Triton, which isn't properly included in StabilityMatrix:
-
Download the Triton wheel from:
https://github.com/woct0rdho/triton-windows/releases -
Install the latest Triton package:
pip install [DOWNLOAD_PATH]\triton-3.2.0-cp310-cp310-win_amd64.whlReplace
[DOWNLOAD_PATH]with the folder where you downloaded the wheel fileNote: The latest version as of this guide is
triton-3.2.0. Ensure you install the version compatible with Python 3.10:triton-3.2.0-cp310-cp310-win_amd64.whl
5. Install SageAttention (Requires Manual Compilation)
🚨 Important: pip install sageattention does not work for versions > 2, so manual building is required.
📌 Step 1: Set Environment Variables
set SETUPTOOLS_USE_DISTUTILS=setuptools
📌 Step 2: Copy Missing Development Files
StabilityMatrix's Python installation lacks development headers that need to be copied from your system Python.
A. Copy Python Header Files (Python.h)
-
Source: Navigate to your system Python include directory:
[SYSTEM_PYTHON_PATH]\includeReplace
[SYSTEM_PYTHON_PATH]with your Python 3.10 installation path (typicallyC:\Users\[USERNAME]\AppData\Local\Programs\Python\Python310orC:\Python310) -
Copy all files from this folder
-
Paste them into BOTH destination folders:
[YOUR_STABILITY_MATRIX_PATH]\Data\Packages\ComfyUI\venv\Scripts\Include [YOUR_STABILITY_MATRIX_PATH]\Data\Packages\ComfyUI\venv\include
B. Copy the Python Library (python310.lib)
-
Source: Navigate to:
[SYSTEM_PYTHON_PATH]\libsReplace
[SYSTEM_PYTHON_PATH]with your Python 3.10 installation path (typicallyC:\Users\[USERNAME]\AppData\Local\Programs\Python\Python310orC:\Python310) -
Copy
python310.libfrom this folder -
Paste it into:
[YOUR_STABILITY_MATRIX_PATH]\Data\Packages\ComfyUI\venv\libs
📌 Step 3: Install SageAttention
-
Clone the SageAttention repository:
git clone https://github.com/thu-ml/SageAttention.git [TARGET_FOLDER]\SageAttentionReplace
[TARGET_FOLDER]with your desired download location -
Install SageAttention in your ComfyUI virtual environment:
pip install [TARGET_FOLDER]\SageAttention
6. Activate Sage Attention in ComfyUI
Add --use-sage-attention as a start argument for ComfyUI in StabilityMatrix.
A note of my own: you can use pip install triton-windows now instead of the prebuilt wheel if you prefer.
We're also making solid progress getting a newer, more compatible Python version that won't need so many hacky workarounds, and since it seems to be getting more popular now, look out for an "install sage attention" button in the app in the future that will automate all this.
I also found these pre-made SageAttention wheels which might help:
https://github.com/woct0rdho/SageAttention/releases
But I'd also love to see PY 3.12...
Getting SageAttention working was definitely not straight forward. I was already using a Triton wheel, but getting errors. I followed the instructions above and installed triton-windows. That installed 3.3.0, I got different errors. But 3.2.0 was available, and now I finally got SageAttention working as well as TorchCompiling my models with the KJ nodes.