Skip to content

No module named 'sageattention' [my issue solution/fix] #10709

@btitkin

Description

@btitkin

Custom Node Testing

Your question

I struggled for a while with getting SageAttention to work in ComfyUI on Windows 11. The main error was ModuleNotFoundError: No module named 'SageAttention', even though pip kept saying the package was already installed. The root cause turned out to be that I had installed the wheel into the wrong Python instance. ComfyUI runs inside its own virtual environment, and you must install SageAttention into that exact python.exe, not the system Python. Another source of confusion was that the module name is lowercase (import sageattention), not SageAttention, and the package does not expose a __version__ attribute, so trying to print it will fail.

The fix was to go into the ComfyUI venv Scripts folder and use the embedded Python directly. First I checked the version with:
cd D:\StabilityMatrixAI\Packages\ComfyUI\venv\Scripts .\python.exe -V

It showed Python 3.12.11, which matched my setup. Then I downloaded the correct wheel for my environment, which was sageattention-2.1.1+cu24torch2.5.1-cp312-cp312-win_amd64.whl (because I use Python 3.12 and Torch 2.5.1+cu121). I installed it with:
.\python.exe -m pip install --force-reinstall C:\SageAttention\sageattention-2.1.1+cu24torch2.5.1-cp312-cp312-win_amd64.whl (your directory for .whl)

After that, importing worked fine:
.\python.exe -c "import sageattention; print(dir(sageattention))"

This showed all the functions inside the module, which confirmed that it was installed correctly. There is no __version__ attribute, but that is expected.

Along the way I also had to resolve dependency conflicts. Torchscale required timm==0.6.13 while open-clip-torch needed timm>=1.0.17. The workaround was to reinstall torchscale with --no-deps so that timm 1.0.22 could stay. Inference-cli and inference-gpu required numpy<=1.26.4 and opencv-contrib-python<=4.10.0.84, so I downgraded numpy to 1.26.4 and opencv-contrib-python to 4.10.0.84. Finally, I installed nvidia-ml-py to silence the deprecation warning about pynvml.

After these steps ComfyUI started cleanly, SageAttention nodes loaded, and everything worked. The key lessons are: always install wheels into the exact python.exe ComfyUI uses, match the wheel to your Python/Torch/CUDA version, import with lowercase sageattention, and don’t be confused by the missing __version__ attribute. Once you do that, the nodes depending on SageAttention will run without errors.

Logs

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    User SupportA user needs help with something, probably not a bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions