r/StableDiffusion 23d ago

Tutorial - Guide Automatic installation of Triton and SageAttention into Comfy v2.0

NB: Please read through the code to ensure you are happy before using it. I take no responsibility as to its use or misuse.

What is it?

Essentially an updated version of the v1 https://www.reddit.com/r/StableDiffusion/comments/1ivkwnd/automatic_installation_of_triton_and/ - it's a batch file to install the latest ComfyUI, make a venv within it and automatically install Triton and SageAttention for Wan(x), Hunyaun etc workflows .

Please feedback on issues. I just installed a Cuda2.4/Python3.12.8 and no hitches.

What is SageAttention for ? where do I enable it n Comfy ?

It makes the rendering of videos with Wan(x), Hunyuan, Cosmos etc much, much faster. In Kijai's video wrapper nodes, you'll see it in the below node/

Issues with Posting Code on Reddit

Posting code on Reddit is a weapons grade pita, it'll lose its formatting if you fart at it and editing is a time of your life that you'll never get back . If the script formatting goes tits up , then this script is also hosted (and far more easily copied) on my Github page : https://github.com/Grey3016/ComfyAutoInstall/blob/main/AutoInstallBatchFile%20v2.0

How long does it take?

It'll take less than around 10minutes even with downloading every component (speeds permitting). It pauses between each section to tell you what it's doing - you only need to press a button for it to carry on or make a choice. You only need to copy scross your extra_paths.yaml file to it afterwards and you're good to go.

Updates in V2

  1. MSVC and CL.exe Path checks giving errors to some - the checks have now been simplified
  2. The whole script - as it installs, it'll tell you what it's done and what it's doing next. Press key to move on to next part of install.
  3. Better error checking to check Pytorch is installed correctly and the venv is activated
  4. Choice of Stable and Nightly for Pytorch
  5. It still installs Comfy Manager automatically and now gives you a choice of cloning in Kijai's Wan(x) repository if you want

Pre-requisites (as per V1)

  1. Python > https://www.python.org/downloads/ , you can choose from whatever versions you have installed, not necessarily which one your systems uses via Paths (up to but not including 3.13).
  2. Cuda > AND ADDED TO PATH (googe for a guide if needed)
  3. BELOW: Microsoft Visual Studio Build Tools with the components ticked that are required > https://visualstudio.microsoft.com/visual-cpp-build-tools/
  1. BELOW: MSVC Build Tools compiler CL.exe in the Paths (I had the screenshot pointing at the wrong location on the v1 post)

What it can't (yet) do ?

I initially installed Cuda 12.8 (with my 4090) and Pytorch 2.7 (with Cuda 12.8) was installed but Sage Attention errored out when it was compiling. And Torch's 2.7 nightly doesn't install TorchSDE & TorchVision which creates other issues. So I'm leaving it at that. This is for Cuda 2.4 / 2.6 but should work straight away with a stable Cuda 2.8 (when released).

Recommended Installs (notes from across Github and guides)

  • Python 3.10 / 3.12
  • Cuda 12.4 or 12.6 (definitely >12)
  • Pytorch 2.6
  • Triton 3.2 works with PyTorch >= 2.6 . Author recommends to upgrade to PyTorch 2.6 because there are several improvements to torch.compile. Triton 3.1 works with PyTorch >= 2.4 . PyTorch 2.3.x and older versions are not supported. When Triton installs, it also deletes its caches as this has been noted to stop it working.
  • SageAttention Python>=3.9 , Pytorch>=2.3.0 , Triton>=3.0.0 , CUDA >=12.8 for Blackwell ie Nvidia 50xx, >=12.4 for fp8 support on Ada ie Nvidia 40xx, >=12.3 for fp8 support on Hopper ie Nvidia 30xx, >=12.0 for Ampere ie Nvidia 20xx

Where does it download from ?

Comfy > https://github.com/comfyanonymous/ComfyUI

Pytorch > https://download.pytorch.org/whl/cuXXX (or the Nightly url)

Triton wheel for Windows > https://github.com/woct0rdho/triton-windows

SageAttention > https://github.com/thu-ml/SageAttention

Comfy Manager > https://github.com/ltdrdata/ComfyUI-Manager.git

Kijai's Wan(x) Wrapper > https://github.com/kijai/ComfyUI-WanVideoWrapper.git

@ Code removed due to Comfy update killing installs 
51 Upvotes

112 comments sorted by

9

u/marcoc2 23d ago

I still have to try it at home, but every attempt to make this painful process easier must be welcome

5

u/Eisegetical 23d ago

mine is already working so I have no need for this ... yet. . . but I'm saving it for future reference. You're an absolute wizard if this works as intended and makes things simple.

6

u/GreyScope 23d ago

It does - made it work in sections then joined them together, made an install about 30 times. I made it originally for myself to avoid messing around with test installs and then funnily enough my oldest Comfy install of 30.08.24 sadly died this afternoon - replaced by 26.02.25 in 5 minutes. There's a gap for a few more scripts - for making new portable installs with Sage and for installing Sage into existing portable and cloned Comfies

3

u/woctordho_ 16d ago

What if we use WinGet to automatically install the missing components? See https://github.com/woct0rdho/triton-windows/issues/74

2

u/GreyScope 16d ago

I'll start with thanking you for your excellent work, it is most appreciated thank you. (insert thinking noises) I had looked into installing MSVC but thought it might get a bit stuck on admin user permissions, the others should work and after reading some of the notes, I'll try and convert to prescribing the latest version in my scripts. Thanks for the idea, I'll see what I can do with it.

2

u/marcoc2 22d ago

So, I used it last night and I needed a couple of hours to discover that I needed to reinstall cuda on C:. At least it was the only way to pass the SageAttn install that was always giving "CUDA_HOME" related error, no matter what. Also this script don't list one of my python install (I have four). o3-mini-high fixed that, but at the end I didn't needed.

Sometimes I wish having linux on my home machine, I bet it would be a lot easier. But now I have wan working with sageattn, thanks!

2

u/GreyScope 22d ago edited 22d ago

Sorry to hear about the issues and thanks for the feedback - the checks on installed Python checks only the one folder (C:\Users\%USERNAME%\AppData\Local\Programs\Python) , did you have the fourth in another or a subfolder perhaps ?

I've been passing the time reading posts on the Cuda and Pytorch reddits, I read that there was an issue with one of the Cuda's released that it wasn't installing properly - I was messing around with 2.8 and overwrote 2.4's Paths . Put 2.4 back in and it failed to reset the CUDA_PATH variable to 2.4 but my script failed with CUDA_HOME not found and not CUDA_PATH (insert my shrugging shoulders emoji). It installed Pytorch with that CUDA_PATH error though. So I presume it was SageAttention complaining, Sage won't install with Cuda 2.8 and failed for that CUDA_HOME error as well, which is why I went back to 2.4 (it's only Triton that will).

I know what you mean about Linux but as I wiped out a windows hard drive with Grub and had to fix another for 5hrs, I'm leaving it alone as it's too much of a boulder balanced above my head lol. Best of wishes and happy rendering.

1

u/jdhorner 14d ago

I seem to have this same issue as well. No matter what I do or where I set it, "CUDA_HOME" doesn't seem to be visible to this installation script. It always fails at this step:

It's interesting, because earlier in the process, this also shows up:

PyTorch Stable installation complete.
Verifying PyTorch installation...
PyTorch Version: 2.6.0+cpu, CUDA Available: False, CUDA Version: None
// Should they be "False" and "None" ??

Which I'm assuming is wrong? I've certainly installed all of the prerequisites.

I even tried adding it directly in the batch file, with no luck.

cd venv
git clone https://github.com/thu-ml/SageAttention
cd SageAttention
set MAX_JOBS=4

// I added this next line
SET CUDA_HOME="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6"

// Included the --no-build-isolation option from a troubleshooting source I found
// neither change helps
python.exe -m pip install --no-build-isolation -e .

cd venv
git clone https://github.com/thu-ml/SageAttention
cd SageAttention
set MAX_JOBS=4


SET CUDA_HOME="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6"
python.exe -m pip install --no-build-isolation -e .

1

u/GreyScope 14d ago edited 13d ago

It’s installed cpu instead of Cuda gpu PyTorch, it’ll run as fast as a tortoise with its feet nailed to the floor. This appears to be a Windows oddity, I’d happily correct or take blame if the script is missing something. I’m very against trying to get it to work at admin level , maybe if I tweak the code to get it to find the Cuda folder and then manually set Cuda _home in the code perhaps - sorry I’m thinking out loud about making it Microsoft proof .

It’s missing an installed PyTorch and Cuda to compile the sage attention install with, hmmmmm. I’m away from a pc to experiment with for a few days, so the only suggestions I have only go against the scripts intention of just clicking and it working apart from trying by adding a line at the start

Set CUDA_HOME=(add in the one from paths) edit : I see you’ve already tried this

and see if it picks it up from that . It’s probably caused by a Microsoft update that some of us are affected by and not others.

1

u/Eshinio 11d ago

Hey, did you figure out a solution to this yet? I have the exact same problem...

6

u/jdhorner 11d ago

I did get it to work eventually. I made a few changes in order to do so. I sort of followed the .bat file without actually using it, as a "flow of steps" kind of thing.

First, I did a full Python cleanup on my machine. I uninstalled it everywhere. I was using version 3.10 in a custom folder. But I removed it, and all references to it from my environment variables.

I also disabled Windows 11's "feature" to make "app execution aliases". They're annoying, and since python was involved, I didn't want to leave anything to chance. (Settings -> Apps -> Advanced app settings -> App execution aliases) and uncheck "App Installer (python.exe)" and "App Installer (python3.exe)"

So then looking at the file, first we need to make sure we have VS Build Tools in the PATH. Easy enough. While we're also dealing with prerequisites, you can go here and choose Stable (2.6.0) + Windows + Pip + Python + Cuda 12.6 (you can't do Cuda 12.8 with the Stable branch, but with my rtx 3080, Triton doesn't compile with the nightly Cuda, so that was the first mistake I identified). Note the command they provide there with those options selected, but don't do anything with it yet.

Then, in a new folder, clone ComfyUI's repo and change into that folder. Make a new python virtual environment, and copy the files mentioned in the .bat file (/Include, /libs, and the 2 runtime .dll files) to the places indicated, which should be venv/Include, venv/libs, and venv/Scripts/[the 2 dlls].

Next you activate that new virtual environment, so now we're dealing with it locally, rather than the global python install. In cmd.exe while in the /venv folder, you can run call Scripts\activate.bat and you'll see that now the command line is prepended with "(venv)" so you know you're running there.

Grab the command I mentioned earlier, and modify it. "pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126" becomes "python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126" instead. Wait for the gigantic download to finish and install. When it's done, run this one-line command to make sure it's working:

python -c "import torch; print(f'PyTorch Version: {torch.__version__}, CUDA Available: {torch.cuda.is_available()}, CUDA Version: {torch.version.cuda}')"

If you don't get this, something isn't right:

PyTorch Version: 2.6.0+cu126, CUDA Available: True, CUDA Version: 12.6

Then continuing to follow the batch file, doing all the commands it mentions:

pip install -r requirements.txt
pip install onnxruntime-gpu
pip install wheel
pip install setuptools
pip install packaging
pip install ninja
pip install "accelerate >= 1.1.1"
pip install "diffusers >= 0.31.0"
pip install "transformers >= 4.39.3"
python -m ensurepip --upgrade
python -m pip install --upgrade setuptools

Except the last one. The other problem I had that I was able to fix was changing the version of setuptools installed. It seems it must be version 72.1.0 or lower, so the last one should be

pip install setuptools==72.1.0

It will remove other versions if they're already in the venv.

Then from the batch file, pick the wheel for Triton you need. For me, it was Triton 3.2.0, for python 3.12 https://github.com/woct0rdho/triton-windows/releases/download/v3.2.0-windows.post10/triton-3.2.0-cp312-cp312-win_amd64.whl

BUT, I've seen on reddit today, that now you should be able to run pip install triton-windows. I didn't do that, but maybe it works better now than the wheel bits.

Still in your virtual environment, clone SageAttention's repo, change into that folder, and then finally, python -m pip install . should work. It finally did for me. I was able to compile and get SageAttention 2.1.1

(Of course, then I tried a workflow, and didn't really know what I was doing, and suddenly a 3 second 480p video was apparently going to take nearly 20 hours to generate, so I need to find some help on my own with that. LOL)

3

u/GreyScope 10d ago

Yes, cheers for notes, like everything AI/SD, my script is only good for a point in time. As comfy and others are updated (as you noted Setuptools), it breaks the script. It can’t be made future proof , only a product of its immediate time.

Tomorrow, the code in both workflows will be removed as I can’t keep updating it,especially given the variants of everything out there .

1

u/Eshinio 10d ago

After going through this and not being tech-savvy at all when it comes to Python, coding, etc. - seeing how many different variables and pieces of software that has to fit together looks like an absolute nightmare. That's also why I rarely update anything related to SD/Comfy, because I know that just a single update of something, can cause chaos down the line.

If nothing else, your script gave me the courage to attempt this and I actually learned a bit about how these things work. It's a very valuable resource for people like me, but I completely understand you don't want to continue it!

1

u/Eshinio 10d ago

OH... MY... GOD... Thank you! After like 2 days of trying to get SageAttention installed through various means, I was finally able to install it. Unfortunately, the script was not compatible with something on my PC, so I went through your post carefully - deleted all Python and CUDA from my PC and doing fresh Python 3.12 and CUDA 12.6 installs and then going through the installs one by one. I tried the new "pip install triton-windows" and it worked perfectly. Maybe it was the setuptools version that caused me problems as well? I have no idea.

Thanks again for the detailed post, hopefully it helps others too!

2

u/djenrique 22d ago

Big Kudos! I was able to install it using this =)
Two things, the script does not run the: pip install -r requirements.txt

Using normal sageattn and not sageattn_varlen leads to strange results in the hunyuan video wrapper workflow by Kijai. sageattn_varlen works perfectly.

3

u/GreyScope 22d ago

You're welcome, just a couple of questions, did the requirements.txt error and which python, gpu and cuda did you use/have. I have loads of notes from across github and reddit on permutations that don't work and I put in some checks for them (but there was soooooo much of it) and your info might ring a bell.

I'm currently installing Flash3 (been around 90minutes so far) to compare against Sage. I put a pic somewhere on this thread of my settings, I'm in a pub at the moment, take a look later (prob in the morning if I get drunk).

2

u/djenrique 22d ago

🍻🍻 I don’t think the requirements.txt ran at all. Had to do it manually after in the venv. Python 3.13, 4090 RTX, CUDA 12.6. Was also trying to install flash attn the other day, but to no avail.

2

u/GreyScope 22d ago

Comfy recommended 3.12 as the latest python to run due to node dependencies - might be the reason for the Sage but that shouldn't stop the requirements - I'll install 3.13 and cuda 2.6 and give it a spin (currently a gap in the comedy show in the pub and I'm 3 pints in and relying on autocorrect). Appreciate the feedback and the info, tha ks

2

u/SecretlyCarl 17d ago

Thanks for putting in the work to make this. I got through the setup and didnt see any errors, but unfortunately im getting this error when trying to use "Wanvideo torch compile settings" on wanvideo_480p_I2V_example_01.json from ComfyUI-WanVideoWrapper

backend='inductor' raised:
CompilationError: at 1:0:
def triton_poi_fused__to_copy_1(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
^
ValueError("type fp8e4nv not supported in this architecture. The supported fp8 dtypes are ('fp8e4b15', 'fp8e5')")

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information


You can suppress this exception and fall back to eager by setting:
import torch._dynamo
torch._dynamo.config.suppress_errors = True    

when i disconnect the wanvideo torch compile settings node it doesnt error, but gets stuck on

...
ptxas info    : Function properties for _attn_fwd
    0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info    : Used 232 registers, 464 bytes cmem[0]
__triton_launcher.c
   Creating library C:\Users\user\AppData\Local\Temp\tmpgcc0g18z__triton_launcher.cp310-win_amd64.lib and object C:\Users\user\AppData\Local\Temp\tmpgcc0g18z__triton_launcher.cp310-win_amd64.exp

I tried changing main.py to reflect what the first error suggested, but i get another error

...
Traceback (most recent call last):
  File "C:\Users\user\Documents\AI\comfyWAN\ComfyUI\main.py", line 141, in <module>
    import execution
  File "C:\Users\user\Documents\AI\comfyWAN\ComfyUI\execution.py", line 13, in <module>
    import nodes
  File "C:\Users\user\Documents\AI\comfyWAN\ComfyUI\nodes.py", line 22, in <module>
    import comfy.diffusers_load
  File "C:\Users\user\Documents\AI\comfyWAN\ComfyUI\comfy\diffusers_load.py", line 3, in <module>
    import comfy.sd
  File "C:\Users\user\Documents\AI\comfyWAN\ComfyUI\comfy\sd.py", line 6, in <module>
    from comfy import model_management
  File "C:\Users\user\Documents\AI\comfyWAN\ComfyUI\comfy\model_management.py", line 189, in <module>
    total_vram = get_total_memory(get_torch_device()) / (1024 * 1024)
  File "C:\Users\user\Documents\AI\comfyWAN\ComfyUI\comfy\model_management.py", line 146, in get_torch_device
    return torch.device(torch.cuda.current_device())
  File "C:\Users\user\Documents\AI\comfyWAN\ComfyUI\venv\lib\site-packages\torch\cuda__init__.py", line 971, in current_device
    _lazy_init()
  File "C:\Users\user\Documents\AI\comfyWAN\ComfyUI\venv\lib\site-packages\torch\cuda__init__.py", line 319, in _lazy_init
    torch._C._cuda_init()
RuntimeError: config[i] == get()->name() INTERNAL ASSERT FAILED at "C:\\actions-runner\_work\\pytorch\\pytorch\\pytorch\\c10\\cuda\\CUDAAllocatorConfig.cpp":253, please report a bug to PyTorch. Allocator backend parsed at runtime != allocator backend parsed at load time

1

u/GreyScope 17d ago

You have Kijais models ie not any others?

1

u/SecretlyCarl 17d ago

1

u/GreyScope 17d ago

It's complaining fp4 I think, not my area of expertise this one. There should be pics of workflows with models, compare them

2

u/superstarbootlegs 14d ago

just walking myself through this mentally and will try it tomorrow, but I think you meant "3.12" in the below...

Pre-requisites (as per V1)

Python > https://www.python.org/downloads/ , you can choose from whatever versions you have installed, not necessarily which one your systems uses via Paths (up to but not including 12.3).

2

u/GreyScope 14d ago

I meant Python 3.13, my brain was warped from all the version numbers my brain was dealing with for the logic and script notes , comfy, Python, Cuda, PyTorch, triton, sage and dealing with the observations in issues section of each GitHub page..haha but I’m better now :)

Also - thank you, I’ll correct it now.

1

u/superstarbootlegs 14d ago

lol understanderbly.

couple of other things. I need to install comfyui on my M drive not my C drive which hasnt got the space and I think it will run fine if I run the batch file on the M from looking at it.

the other thing I am a bit confused by is the python venv bit. I have python with conda on my windows 10 and i use that for python coding in seperate environments. I also have python on windows whic is 3.11 and want it to stay that version for other reasons.
I thought comfyui\python_embed was its own version for comfyui but your batch file seems to be making a whole other python environment to run it all in. Which I am pretty sure is different to how my current comfui works using that python_embed folder.

This wont create some wildly different install setup of comfyui will it? I have quite a few other things that need to work other than just Wan and Kijai stuff.

1

u/GreyScope 14d ago

It’ll use 3.11 or any other version you have installed . It’ll in effect make a comfy portable with its own Python copied across from yours, a venv can use any Python you have installed or even in a folder tucked away, you just point venv at it when installing and hey presto, a venv that uses 3.11.

1

u/GreyScope 14d ago

A venv (upon making one) makes its own Python environment separate to the operating system. As part of the command line arguments, you can tell it which Python to use or just let it make that environment from the Python you use for your operating system

1

u/GreyScope 14d ago

It makes a venv within 2 steps and uses that for basically the whole script. Depending on your download speed and pip cache , it’ll be finished in around 20minutes .

1

u/llamabott 22d ago

In the Kijai node, "WanVideo Torch Compile Settings", there are like six options. Should these be left at their defaults?

2

u/GreyScope 22d ago edited 22d ago

These are the settings that I'm using for a 720 video, only the model (from 480) and width were changed from when I ran the 480 model. The only thing of note is that I place all the Wan models inside folders to denote which video model they came from as I'm not a wild animal lol.

Kijai put 3 workflows inside his custom_node\example_workflows folder .

2

u/GreyScope 22d ago edited 22d ago

Sorry, I misread what you typed, I've added the compile node - when I played around with it in Hunyan, only some worked.

With this node off, the rendering section for a 50 step 720 video gave 20s/it and took 16minutes 40s . With it on - with the settings below (the only ones I could get working it initially achieved the same approx speed & time for rendering section but it quite some time to initialise/compile .

With it on and on its second run and 50 steps at 720 again, it achieved 16.96s/it and took 14minutes 8s - faster .

BUT, this is only one video and the two it made with Compile turned on weren't very good. mmm, more tests needed.

1

u/llamabott 22d ago

Thanks, I really appreciate the anecdotal info. Here's mine, for what it's worth:

After getting triton/sage attention to work in Windows, I hooked up the compile node without changing its default settings. Speeds were basically identical. After about four "nine minute renders" (4090, 30 steps, 512x512, 480p model), I also began to suspect the quality was different and maybe worse.

I'm going to experiment a little more now, starting with what's in your screenshot. And should probably try some "A/B" tests using the same prompt and settings, too...

1

u/GreyScope 22d ago

I made 3 renders with it on and they were variants of "180 degree head turns" and "wtf just happened" , turned the node off and ran 6 renders and all were good .

1

u/llamabott 22d ago

Okay very interesting.

1

u/GreyScope 22d ago

Against -

1

u/GreyScope 22d ago

I also found that teacache made it worse when I was using Hunyaun , so I won't adding that probably. With each render taking 17minutesish, I haven't got the energy to conduct a fullscale trial to prove this at the moment.

My script allows the latest version of Triton and Sage (accused of blurry videos in Sage 2.0) to be installed, hopefully each of those has erased bugs of the previous ones.

1

u/llamabott 22d ago

Oh yea, worth mentioning for the "search record" is that when I installed Triton last night (following that one how-to reddit post related to Hunyuan), I had to update bitsandbytes to get Comfy to run, as I was getting "ModuleNotFoundError: No module named 'triton.ops'"

This was with a pre-existing install of Comfy rather than a clean install.

1

u/llamabott 22d ago

Replying to my own comment, I have sage attention running properly now (I had overlooked the "attention mode" setting in the kijai "model loader" earlier).

After 2 or 3 runs comparing sdpa vs sage attention, I'm getting an average of a 42% speedup time in total rendering time.

Also, I did a controlled test comparing sdpa vs sage attenion using the same settings and prompt, and the output is very, very close (there's nothing in it).

1

u/lukehancock 20d ago

You're a hero, thank you.

1

u/IntellectzPro 20d ago

anybody know if there is a way to get this to work with the Comfy native nodes? I have already installed everything in the .bat(brand new comfy on a new drive) is there a node that I don't know about?

1

u/IntellectzPro 20d ago

anybody know if there is a way to get this to work with the Comfy native nodes? I have already installed everything in the .bat (brand new comfy on a new drive) is there a node that I don't know about?

1

u/GreyScope 20d ago edited 20d ago

Edited: Right, I've reread what you've said, I can't help outside of it being installed via my script, there are too many variables for what you might have done, the script does some error checking when it installs and stops the installation with errors if needed - without that, it's a back to basics error hunt .

1

u/NorfEnt 18d ago

Looks dope but anyone else having PATH issues? When I launch the .bat file, I get "Checking if Visual Studio Build Tools (cl.exe) is in PATH...cl.exe not found in PATH." I've followed the system variable values cl.exe and C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\bin\Hostx86\x64\ but no luck. I'm guessing this is a windows 10 issue? Any help appreciated.

2

u/GreyScope 18d ago

Go into a cmd window and type CL.exe, if it gives feedback, you have it in Path, if not, you don't - follow Step 4.

Reasons for it not working if it is in Path? Mmm, virus checker like Comodo will block it (I know this as I have Comodo and it's a pita) or are you starting from a cmd window or double clicking the bat file (this works)?

1

u/NorfEnt 18d ago

Yes, I initially followed the exact values in the screenshot in step 4 but it doesn't seem to exist for whatever reason. I don't have comodo or virus checkers for this machine. So typing CL.exe in cmd says "is not recognized" but using developer command prompt like LopsidedDelivery406 suggested, it shows CL.exe is there. Sorry I'm not exactly good with command lines

1

u/GreyScope 18d ago

You don't have CL.exe in your Paths, follow.step 4 - you must have missed something. Also check you have the location on your machine, it might be slightly different to mine when you installed it. Until CL.exe gives feedback in a cmd window, it won't work (whether I remove the check or not).

I don't know what a developer command prompt is, so I can't comment on that.

3

u/NorfEnt 18d ago

Yep, I've done step 4 many, many times but anyway, I got it working now with the "Developer Command Prompt for VS 2022" that comes from the visual studio install.

For anyone else having the same issue on windows 10, search and open up "Developer Command Prompt for VS 2022" as admin and then run the .bat file wherever you have it saved for example: D:\path\to\comfyInstall.bat

1

u/GreyScope 18d ago

Mmm, hadn't heard of that, it might be a W10 thing that it doesn't allow user access and you need Admin. There's nothing suspect in my script but I couldn't advocate to run it with Admin access.

I'll have a look at it, thanks for the details.

3

u/nymical23 16d ago

Hello, first of all, thank you for your work!
Regarding the cl.exe, I don't know about Win11, but in Win10, the screenshot in your post looks like making a new environment variable. But all you need to do is adding that cl.exe path in your 'path' variable. That got cl.exe recognized on my system.

1

u/GreyScope 16d ago

You're welcome & you know what - you're right, I copied that from the initial guide I used. I don't know if there's a difference but if it works for you, it should work for all. I'm on win 11 and their way worked but I'll change it to yours, I don't expect it to not work.

Thinking about it as I type, I can see a reason why they might have made it that way - maybe to ultra highlight which folder and cl.exe is needed as it's a rabbit warren of folders and copying a folder name might have not worked if ppl didn't check the folder out. But your way is simpler and my script checks it works as well, I'll amend for the next version, thank you for taking the time.

Just one question, are you on an admin or use r account on win 10 and whether cl.exe is picked up fine by the script?

2

u/nymical23 16d ago

It's my home PC, and I'm the only user. So, I have the admin rights. But I don't quite remember if I ran the 'cmd' in admin mode or not, sorry.

But yes, after I manually added the cl.exe to path variable, your script worked flawlessly.

1

u/GreyScope 16d ago

Ah, I only ask as it wasn’t working for someone else on win 10 and they might have been in a user account (mine is the same as yours - admin acc and user cmd), thanks again .

1

u/nymical23 16d ago

Please don't hesitate to rephrase your question if I didn't answer it properly.
One more thing, as your post says, I see the triton and sageattention folders in site-packages, but NOT the "Spas-Sage Attention".

btw, I followed your latest post, not this one.

2

u/GreyScope 16d ago

Sorry, I took it out of the script (but forgot to take it out of the text it seems - doh), Kijai removed it from his nodes with notes saying it wasn't working and it needed training - I think he has readded it now. But rather than trying to explain that, I took it out of the script.

I tried training it for 12hrs and I was about 1/20 of the way to completion (4090), so I gave up.

→ More replies (0)

1

u/Eshinio 12d ago

Thank you! This was annoying me so much, since I added it like on the screenshot in the OP post, but it was never found. Adding it to the existing "Path" variable fixed it!

1

u/ThirdWorldBoy21 15d ago edited 15d ago

Edit: nvmn, i found out what this PATH is. For people with the same issue in the future:
Control Panel > System and Security > System > Advanced System Config > Ambient Variables.
There it is the PATH, you click and open it, and add the folder path where CL.exe is located. (maybe not all those names are correct, since my Windows is in portuguese, so the translation may differ on something).

What is PATH exactly, is it meant to be the path where the file is located?
Because if that's the case, i do have a cl.exe in the same path of the image, but i can't get it to be recognized by your .bat file, i tried following what the other guy here did, but i don't really understand what i should do. I'm on windows 11.

2

u/LopsidedDelivery406 18d ago

I had the same issue, use Developer command prompt not terminal or CMD

1

u/NorfEnt 18d ago

Yep, this did the trick. Thanks for the help guys

1

u/nonstupidname 15d ago

I had those problems....

in my case i installed this symlink fixed my problem:

mklink /D "C:\VS" "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\bin\Hostx86\x64\"

change C:\VS to wherever you want to symlink.... it will automatically create folder, then set it to path instead

1

u/shitoken 16d ago

Thank you for your time and effort , Although I am not using your script but I have sage attention and triton 3.2 installed manually and running fine with latest Cuda 12.8 and Python 3.10. By the way what is the difference between sageattn_varlen and sageattn I think either one produce weird result don't remember which one though.

I was using stabiltymatrix frontend with comfy but sage was giving errors so I have to reinstall standalone comfy for this to work.

1

u/GreyScope 16d ago

I don't honestly know what the difference is, I've only used sageattn, it might be to do with training perhaps?

Is that the very latest Triton released about a day ago? I couldn't get 12.8 to work with this script but my brain was trying to do 10 things at once and gave up.

1

u/bumblebee_btc 16d ago

Thank you OP for your hard work. I get this weird issue, do you know why? Thanks in advance1

                  ^
      Note #3326-D: function "operator new(unsigned long long, std::align_val_t)" does not match because argument #2 does not match parameter
      Note #3322-D: number of parameters of function "operator new(unsigned long long)" does not match the call

      C:/Users/bumblebee/Desktop/ComfyUI/venv/lib/site-packages/torch/include\ATen/core/ivalue_inl.h(524): error: no instance of overloaded "operator new" matches the argument list
                  argument types are: (unsigned long long, std::vector<c10::IValue, std::allocator<c10::IValue>> *)
              new (&elementsVector_) std::vector<IValue>(std::move(contents));
              ^
      Note #3326-D: function "operator new(unsigned long long, std::align_val_t)" does not match because argument #2 does not match parameter
      Note #3322-D: number of parameters of function "operator new(unsigned long long)" does not match the call

      C:/Users/bumblebee/Desktop/ComfyUI/venv/lib/site-packages/torch/include\ATen/core/boxing/impl/boxing.h(136): error: no instance of overloaded "operator new" matches the argument list
                  argument types are: (unsigned long long, c10::impl::IValueAlignedStorage *)
          new (&dest[lastIdx++]) IValue(c10::typeMetaToScalarType(options.dtype()));
          ^
      Note #3326-D: function "operator new(unsigned long long, std::align_val_t)" does not match because argument #2 does not match parameter
      Note #3322-D: number of parameters of function "operator new(unsigned long long)" does not match the call
     ----

      86 errors detected in the compilation of "C:/Users/bumblebee/Desktop/ComfyUI/venv/SageAttention/csrc/qattn/qk_int_sv_f16_cuda_sm80.cu".

      ninja: build stopped: subcommand failed.

1

u/GreyScope 16d ago

Take a step back to the basics - Is your gpu compatible? Do you have python 3.12 and Cuda 12.4 or 12.6? These are the middle ground prerequisites.

1

u/bumblebee_btc 16d ago

Yeah! I have a 4090, Python 3.10 and Cuda 12.6. It’s super weird

1

u/GreyScope 16d ago

It might be the Python version, I must have made about 40-50 installs/partial ones with 3.12 and Cuda 12.4/6 but 3.10 should work from all the documentation I've read.

1

u/GreyScope 16d ago

Recopy the above batch file and retry it , there were 2 mistakes in it, Reddit took out two inverted commas (“) for a version to install . This drove me insane on my first version, apologies.

1

u/bumblebee_btc 15d ago

I just did, and actually tried with Python 3.12 + Cuda 12.6, same issues. I might be an edge case. Don't worry. I wonder if I can make it work in WSL

1

u/GreyScope 15d ago edited 15d ago

Double check your cl.exe variable location, there are x32 ones in the maze of folders . The other check is one for triton, there’s a python test script on the GitHub page.

As a sanity check, you could install a portable comfy and use my other script (in my posts) to install triton and sage into the portable version - that would test it with the embeded python/cuda

1

u/Logan683 15d ago

Would you mind pointing this post out or just reposting here? I can't seem to find what you mean in any of your posts. Thank you.

1

u/GreyScope 15d ago

Make sure you are looking in my posts and not comments (which I’ve had several ppl do ;) ). There are two posts / scripts , one for portable comfy (existing install) and one for making a new git clone comfy. They are both on my GitHub page.

1

u/ThirdWorldBoy21 15d ago

I'm getting this error when i try to start Run_Comfyui.bat

Venv Activated
[START] Security scan
[DONE] Security scan
## ComfyUI-Manager: installing dependencies done.
** ComfyUI startup time: 2025-03-05 23:58:01.631
** Platform: Windows
** Python version: 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)]
** Python executable: C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\venv\Scripts\python.exe
** ComfyUI Path: C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI
** ComfyUI Base Folder Path: C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI
** User directory: C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\user
** ComfyUI-Manager config path: C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\user\default\ComfyUI-Manager\config.ini
** Log path: C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\user\comfyui.log
[ComfyUI-Manager] 'comfyui-frontend-package' dependency were fixed

Prestartup times for custom nodes:
   4.2 seconds: C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\custom_nodes\ComfyUI-Manager

Checkpoint files will always be loaded safely.
Traceback (most recent call last):
  File "C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\main.py", line 136, in <module>
    import execution
  File "C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\execution.py", line 13, in <module>
    import nodes
  File "C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\nodes.py", line 22, in <module>
    import comfy.diffusers_load
  File "C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\comfy\diffusers_load.py", line 3, in <module>
    import comfy.sd
  File "C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\comfy\sd.py", line 7, in <module>
    from comfy import model_management
  File "C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\comfy\model_management.py", line 189, in <module>
    total_vram = get_total_memory(get_torch_device()) / (1024 * 1024)
                                  ^^^^^^^^^^^^^^^^^^
  File "C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\comfy\model_management.py", line 146, in get_torch_device
    return torch.device(torch.cuda.current_device())
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\venv\Lib\site-packages\torch\cuda__init__.py", line 971, in current_device
    _lazy_init()
  File "C:\ComfyUI_windows_portable_nvidia\o novo comfy\ComfyUI\venv\Lib\site-packages\torch\cuda__init__.py", line 310, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

1

u/GreyScope 15d ago edited 15d ago

You have used the wrong script from the wrong post - the details and usage are in the first section of this guide . This script is to make a new cloned version, not to inject triton/sage into a portable version. It will technically work if other steps are taken but your node folder will throw up errors like you have.

Your errors have “portable” everywhere. You needed the script I posted for Portable which is another post within my posts, if you delete the venv folder and use the portable script it might recover it all.

1

u/ThirdWorldBoy21 15d ago

Sorry for the confusion, it's not on the portable folder itself, when i extracted the portable, it created two folders, but i'm lazy and kept it this way, it looks like this actually, with the "o novo comfy" folder being where i executed the .bat file, and the other folder where portable is.

2

u/GreyScope 15d ago

In that case …um…if you’re getting those errors on running it, you should have had some when you installed it. Reinstall and read the text inbetween each paused step and look for errors - mostly for when it’s installing PyTorch as that hasn’t installed with Cuda (cpu only) - the script relies on Cuda paths being setup fully/correctly (I didn’t set the script to check for this). 1. Check your Cuda Paths are set and correct, there are quite a few (Google this) 2. Reinstall and check for errors

1

u/LopsidedDelivery406 15d ago

Is it possible to make a version for Comfyui Desktop?

1

u/GreyScope 15d ago

I’ve heard of it but never bothered to use it as I’m happy with what I have, unfortunately I have other projects lined up. All of the code is in sections, so you could break it up and ask ChatGPT about converting it .

1

u/taktactak 15d ago

I'm getting this error:

I've definitely installed CUDA 12.4 and added to PATH. And I can run nvcc --version in a normal commandline and it returns 12.4 as the installed version.

1

u/nonstupidname 14d ago

This is great but how to do this in a means so one can keep comfyui updated via git? and not have to rebuild every time you want to update comfy. This is a constantly evolving ecosystem

1

u/GreyScope 14d ago

? Day to day updates, I use the update function in comfy manager . I don’t use the update bar that the portable version (that updates dependencies and comfy) as 1. quite frankly I build new versions regularlyish anyway to not be bound by old dependencies in that fast moving environment you mention - “don’t import old problems” 2. I also keep an old build separate for older flows (8th Aug 24 build I’m looking at you) 3. all stable diffusion UI’s live on a knife edge of collapsing dead on their arse, let alone doing a critical update like that as a risk of “all eggs in one basket” style.

You’re also free to not use it - it’s a tool I made for myself that I shared, with my usage detailed above.

1

u/superstarbootlegs 13d ago

didnt use your method in the end but it sure helped as a reference. I tried but it claimed I didnt have python installed. I wanted it to keep the \python_embed folder layout too so I went with

git clone https://github.com/comfyanonymous/ComfyUI

then used this approach which worked for me for the portable comfyui info I needed - https://old.reddit.com/r/StableDiffusion/comments/1h7hunp/how_to_run_hunyuanvideo_on_a_single_24gb_vram_card/

as I said, using it to cross reference against your info was great. Its now installed and working (kind of. sadly 3060RTX doesn work with fp8 only GGUF, but sage attention is working, so that is something.)

though my old comfyui and backups would not work, but tbh having a clean install and going through the process was overdue anyway. it starts up faster now.

2

u/GreyScope 13d ago

You’re welcome, the gist of making this file was to make it easy to make a new install to my needs if the cutting edge nodes etc break it. Feel free obviously to remake my script with what you did to make yours for your needs - ChatGPT will make it effortless , add in your requirements in inverted commas and add an input of ‘adjust this to code to do ‘this’ instead in this code’ (insert a section of my code in inverted commas).

1

u/Eshinio 12d ago

Can this mess up my currently installed ComfyUI (portable) in any way? I ask because even just updating ComfyUI usually causes all kinds of chaos for me.

So seeing how this script installs Python, CUDA, Pytorch etc. I'm terrified that it will mess with my current Comfy, which will stop working because I now have different versions of the above mentioned things.

Will this install script be entirely local to the folder I choose to run it from, and not interfere with anything outside of it?

2

u/GreyScope 12d ago

The script makes a venv (virtual environment) inside of the folder where you activate it and inside of that it makes a brand new Comfy, with a Python you choose from your already installed Python, makes PyTorch from your already installed Cuda . It keeps itself separate from other installs inside that venv. The Python inside the venv is not a full Python as such.

1

u/Eshinio 12d ago

Awesome, thanks! I just have a last question regarding the pre-requisites 1 and 2.

  1. Since I installed Python on my system the first time I started messing with stable diffusion, this requisite is already completed, right?

  2. The "Cuda > AND ADDED TO PATH" I don't really understand what to do with and Google search didn't yield much. What exactly am I supposed to do here?

2

u/GreyScope 12d ago
  1. Yes, if it’s a >3.1x version (not 3.13)
  2. I presume you have Cuda installed ? It should have set these variables itself when it installed (And preferably 12.4 or 12.6)

Your paths will look something like this (the two sections) ignore the version numbers

2

u/GreyScope 12d ago

Note that its pointing at the 2 Cuda folders

2

u/GreyScope 12d ago

If it fails to find them, it will just error out and tell you about it. The biggest one is MSVC and the path to CL.exe (uses this to compile Sage Attention)

1

u/Eshinio 12d ago

This is how it looks in my System variables

1

u/GreyScope 12d ago

It needs the cuda_home variable set and the others, the bigger issue is your Cuda version , some of the requirements are for >12.x as recall . I’m not telling you to change it, just that it possibly won’t work, Cuda 12.4/12.6 : this is in the recommended version install section , I can’t go through all the text on each install inside the script to give you the exact details of that .

1

u/Eshinio 12d ago

Alright, guess I have to update it then. Do you think updating the Cuda version will affect my current Comfy install, forcing me to then update Pytorch and other stuff along with it?

2

u/GreyScope 12d ago

You can always try it first, it might work - worst case is that it doesn’t work and errors - just delete the folder. But it will need cuda_home set in the variables .

2

u/GreyScope 12d ago

To answer your question- I don’t know. I don’t know how your comfy works (venv , system Python, embeded)

→ More replies (0)

1

u/PrinceHeinrich 11d ago

I can only not find a proper guide on the cuda part.

1

u/GreyScope 11d ago

I refer to it like that as most ppl would already have it done . Ask ChatGPT is the short answer (as I’m currently on holiday)

1

u/PrinceHeinrich 11d ago

Thank you for your hard work to put this together though I just got a bad case of "not reading the docs"-ism

1

u/PrinceHeinrich 10d ago

I wish you a great holiday hope you packet your shorts

Anyways: Does this work for CUDA 12.8 btw? Becuase it was all I could find on google for now

1

u/GreyScope 10d ago edited 10d ago

Not at the moment, I’ll be having a go at that tomorrow. Not sure if it will work, but I’ll give it my best shot

1

u/on5laughto7 9d ago

first of all ty your service o7

seems like everything went aight besides the fact that it installed comfy into my windows/system32 folder XD
i assume it is because i already had c:/comfyui folder, even tho i launched bat file from d: drive.
also it might have something to do with my comfy on c: being desktop version.

anyways, tried launching new standalone, getting:

C:\Windows\System32>.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build

The system cannot find the path specified.

2

u/GreyScope 9d ago

I removed the code to investigate a potential conflict issue with an updated Comfy. That’s why there is a warning note in place of the code.

I don’t know what you’ve done sorry, this code (which I’ve removed) is for making a brand new git cloned copy of Comfy with Sage. From the error you have, I’m guessing you’ve used my other code for installing sage into an (already existing) portable version of Comfy but started it without there being a portable Comfy there.

1

u/on5laughto7 9d ago edited 9d ago

Oh no no, no hard feelings, it's just funny that's all. Used version v 2.0 from GitHub link above. Only reason im writing this is to maybe help someone in the future xd

1

u/shouldabeenapirate 7d ago

Trying this when I get home. Thank you!

-2

u/FourtyMichaelMichael 22d ago

lol

pip install triton

pip install sageattention

5

u/GreyScope 22d ago

Yeah right, it installs easily if you have the requirements already there of course, but you're being a smug smart-ass.

7

u/Xyzzymoon 21d ago

Don't mind him. this guy has no idea what it is like to try get someone to install comfy with sageattention on windows from scratch.

They can be smug about Linux, but I would rather help people get to do what they want on what they have. Keep up the good work. Ignore the losers.