How to run HunyuanVideo on a single 24gb VRAM card.

If you haven't seen it yet, there's a new model called HunyuanVideo that is by far the local SOTA video model: https://x.com/TXhunyuan/status/1863889762396049552#m

Our overlord kijai made a ComfyUi node that makes this feat possible in the first place.

How to install:

1) Go to the ComfyUI_windows_portable\ComfyUI\custom_nodes folder, open cmd and type this command:

git clone https://github.com/kijai/ComfyUI-HunyuanVideoWrapper

2) Go to the ComfyUI_windows_portable\update folder, open cmd and type those 4 commands:

..\python_embeded\python.exe -s -m pip install "accelerate >= 1.1.1"

..\python_embeded\python.exe -s -m pip install "diffusers >= 0.31.0"

..\python_embeded\python.exe -s -m pip install "transformers >= 4.39.3"

..\python_embeded\python.exe -s -m pip install ninja

3) Install those 2 custom nodes via ComfyUi manager:

- https://github.com/kijai/ComfyUI-KJNodes

- https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite

4) SageAttention2 needs to be installed, first make sure you have a recent enough version of these packages on the ComfyUi environment first:

  • python>=3.9
  • torch>=2.3.0
  • CUDA>=12.4
  • triton>=3.0.0 (Look at 4a) and 4b) for its installation)

Personally I have python 3.11.9 + torch (2.5.1+cu124) + triton 3.2.0

If you also want to have torch (2.5.1+cu124) aswell, go to the ComfyUI_windows_portable\update folder, open cmd and type this command:

..\python_embeded\python.exe -s -m pip install --upgrade torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

4a) To install triton, download one of those wheels:

If you have python 3.11.X: https://github.com/woct0rdho/triton-windows/releases/download/v3.2.0-windows.post10/triton-3.2.0-cp311-cp311-win_amd64.whl

If you have python 3.12.X: https://github.com/woct0rdho/triton-windows/releases/download/v3.2.0-windows.post10/triton-3.2.0-cp312-cp312-win_amd64.whl

Put the wheel on the ComfyUI_windows_portable\update folder

Go to the ComfyUI_windows_portable\update folder, open cmd and type this command:

..\python_embeded\python.exe -s -m pip install triton-3.2.0-cp311-cp311-win_amd64.whl

or

..\python_embeded\python.exe -s -m pip install triton-3.2.0-cp312-cp312-win_amd64.whl

4b) Triton still won't work if we don't do this:

First, download and extract this zip below.

If you have python 3.11.X: https://github.com/woct0rdho/triton-windows/releases/download/v3.0.0-windows.post1/python_3.11.9_include_libs.zip

If you have python 3.12.X: https://github.com/woct0rdho/triton-windows/releases/download/v3.0.0-windows.post1/python_3.12.7_include_libs.zip

Then put those include and libs folders in the ComfyUI_windows_portable\python_embeded folder

4c) Install cuda toolkit on your PC (must be Cuda >=12.4 and the version must be the same as the one that's associated with torch, you can see the torch+Cuda version on the cmd console when you lauch ComfyUi)

https://preview.redd.it/a1xa4vspv25e1.png?width=822&format=png&auto=webp&s=c7d3dfe4427eadc2cc7007df498a81933779ecba

For example I have Cuda 12.4 so I'll go for this one: https://developer.nvidia.com/cuda-12-4-0-download-archive

4d) Install Microsoft Visual Studio (You need it to build wheels)

You don't need to check all the boxes though, going for this will be enough

https://preview.redd.it/lw25pkxt2g5e1.png?width=1228&format=png&auto=webp&s=0b8029ca3613e9a3f820c7cb89f178362ae69124

4e) Go to the ComfyUI_windows_portable folder, open cmd and type this command:

git clone https://github.com/thu-ml/SageAttention

4f) Go to the ComfyUI_windows_portable\SageAttention folder, open cmd and type this command:

..\python_embeded\python.exe -m pip install .

Congrats, you just installed SageAttention2 onto your python packages.

5) Go to the ComfyUI_windows_portable\ComfyUI\models\vae folder and create a new folder called "hyvid"

Download the Vae and put it on the ComfyUI_windows_portable\ComfyUI\models\vae\hyvid folder

6) Go to the ComfyUI_windows_portable\ComfyUI\models\diffusion_models folder and create a new folder called "hyvideo"

Download the Hunyuan Video model and put it on the ComfyUI_windows_portable\ComfyUI\models\diffusion_models\hyvideo folder

7) Go to the ComfyUI_windows_portable\ComfyUI\models folder and create a new folder called "LLM"

Go to the ComfyUI_windows_portable\ComfyUI\models\LLM folder and create a new folder called "llava-llama-3-8b-text-encoder-tokenizer"

Download all the files from there and put them on the ComfyUI_windows_portable\ComfyUI\models\LLM\llava-llama-3-8b-text-encoder-tokenizer folder

8) Go to the ComfyUI_windows_portable\ComfyUI\models\clip folder and create a new folder called "clip-vit-large-patch14"

Download all the files from there (except flax_model.msgpack, pytorch_model.bin and tf_model.h5) and put them on the ComfyUI_windows_portable\ComfyUI\models\clip\clip-vit-large-patch14 folder.

And there you have it, now you'll be able to enjoy this model, it works the best at those recommended resolutions

https://preview.redd.it/7p72jk4n135e1.png?width=994&format=png&auto=webp&s=6080536822a6a9720baff3f48d91c75105a044d7

For a 24gb vram card, the best you can go is 544x960 at 97 frames (4 seconds).

Mario in a noir style.

I provided you a workflow of that video if you're interested aswell: https://files.catbox.moe/684hbo.webm