Environment Setup and ComfyUI Installation - sleppyrobot/7900XTXBench GitHub Wiki

This guide is for installing ComfyUI and some custom nodes.

The Linux distribution used is Ubuntu 24.04.2 LTS.

Kernel : Linux 6.8.0-41-generic

ROCM Driver : 6.3.1

First we need to create an environment for python, as it makes managing packages easier compared to using the base environment. Python 3.10 has wide compatibility with many packages and custom nodes.

conda create -n ComfyUI_310_ss python=3.10 # Need To Press y
conda activate ComfyUI_310_ss

The PyTorch+ROCm stable release works with Xformers. Using a development release means that xformers needs to be build from source. Triton flash attention 2 also works with both development and stable PyTorch. Lastly their is a community FA2 that works on the 7900XTX which at time of writing is only works on the forward pass but none the less is the fastest for image and video generation.

Install gel-crabs FA2 and Nightly PyTorch - https://github.com/gel-crabs/flash-attention-gfx11/tree/headdim512

    pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm6.3
    pip install packaging
    pip install -U git+https://github.com/gel-crabs/flash-attention-gfx11@headdim512 

Install Xformers and PyTorch - https://github.com/facebookresearch/xformers

pip install -U xformers torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.2.4

Install Triton Flash Attention and Nightly PyTorch - https://github.com/ROCm/flash-attention/tree/main_perf/flash_attn/flash_attn_triton_amd

pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm6.3
cd $HOME
mkdir Comfy
cd $HOME/Comfy
pip install packaging
export FLASH_ATTENTION_TRITON_AMD_ENABLE="TRUE"
git clone https://github.com/ROCm/flash-attention.git Comfy/flash-attention
cd $HOME/Comfy/flash-attention
git checkout main_perf
python setup.py install

Install Nightly PyTorch Only

pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm6.3

Install ComfyUI, ComfyUI Manager and many other custom nodes.

Make a folder to install ComfyUI in Home directory and git clone the custom node repositories.

cd $HOME
mkdir Comfy
cd $HOME/Comfy
git clone https://github.com/comfyanonymous/ComfyUI TestBed/ComfyUI
cd TestBed/ComfyUI
git pull
pip install -r requirements.txt
cd custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager
cd ComfyUI-Manager
git pull
pip install -r requirements.txt
cd
cd $HOME/Comfy/TestBed/ComfyUI/custom_nodes

Most of the custom nodes will already have the requirements installed, for the remaining nodes the "Try Fix" button found in the ComfyUI Manager will fix remaining nodes.

The following nodes are NOT mandatory and based on my preference.

git clone https://github.com/stavsap/comfyui-kokoro
git clone https://github.com/glibsonoran/Plush-for-ComfyUI
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack
git clone https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved
git clone https://github.com/1038lab/ComfyUI-RMBG
git clone https://github.com/crystian/ComfyUI-Crystools
git clone https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite
git clone https://github.com/chflame163/ComfyUI_LayerStyle
git clone https://github.com/ltdrdata/ComfyUI-Inspire-Pack
git clone https://github.com/yolain/ComfyUI-Easy-Use
git clone https://github.com/pythongosssss/ComfyUI-WD14-Tagger
git clone https://github.com/kijai/ComfyUI-KJNodes
git clone https://github.com/pythongosssss/ComfyUI-Custom-Scripts
git clone https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet
git clone https://github.com/Fannovel16/comfyui_controlnet_aux
git clone https://github.com/Acly/comfyui-inpaint-nodes
git clone https://github.com/Gourieff/ComfyUI-ReActor
git clone https://github.com/rgthree/rgthree-comfy
git clone https://github.com/WASasquatch/was-node-suite-comfyui
git clone https://github.com/city96/ComfyUI-GGUF
git clone https://github.com/StartHua/Comfyui_CXH_joy_caption
git clone https://github.com/TTPlanetPig/Comfyui_TTP_Toolset
git clone https://github.com/blepping/comfyui_jankhidiffusion
git clone https://github.com/Jonseed/ComfyUI-Detail-Daemon
git clone https://github.com/XLabs-AI/x-flux-comfyui
git clone https://github.com/cubiq/ComfyUI_essentials
git clone https://github.com/erosDiffusion/ComfyUI-enricos-nodes
git clone https://github.com/TencentQQGYLab/ComfyUI-ELLA
git clone https://github.com/jojkaart/ComfyUI-sampler-lcm-alternative
git clone https://github.com/kijai/ComfyUI-IC-Light
git clone https://github.com/niknah/ComfyUI-F5-TTS
cd ComfyUI-F5-TTS
git submodule update --init --recursive
pip install -r requirements.txt

Lastly start ComfyUI.

The default VAE is fp32, which is slower and takes up more space compared to fp16 or bf16, we can change this to fp16 or bf16 to save VRAM and faster VAE encode and decode, at the cost of unnoticeable accuracy lost. Flux and LTX-Video should use bf16 as fp16 will cause black screen output. Xformers currently does not have support for memory efficient attention and head sizes, which can cause a block. This may be fixed in future release. https://github.com/facebookresearch/xformers/commit/528e5ae2d344b76b5119acc227ea7fac93bb49d4

A way around this is to start comfyUI with PyTorch attention or disable xformers.

cd $HOME/Comfy/TestBed/ComfyUI
python main.py --use-pytorch-cross-attention --fp16-vae --auto-launch

Disable xformers and use FA2. Use this option to use gel-crabs FA2.

cd $HOME/Comfy/TestBed/ComfyUI
python main.py --use-flash-attention --disable-xformers --fp16-vae --auto-launch

Alternatively it can be started with the following launch parameters.

MIOPEN_FIND_MODE has 5 options, setting it to 2 instructions changes the behavior such that, it will fallback to a predictive AI model when faced with a problem it has not optimized for rather than attempting to benchmark solutions for the current problem. This can help save time greatly when using changing resolution or other settings for a new model architecture.

PYTORCH_TUNABLEOP_ENABLED will make generations slower the first time a new resolution is used and it use more RAM, however subsequent generations will be faster. This is a one time penalty.

MIOPEN_FIND_MODE=2 PYTORCH_TUNABLEOP_ENABLED=1 python main.py --disable-xformers --fp16-vae --auto-launch

If Triton FA was installed we must pass the variable FLASH_ATTENTION_TRITON_AMD_ENABLE="TRUE" each time a new instance of the terminal is opened.

FLASH_ATTENTION_TRITON_AMD_ENABLE="TRUE" python main.py --use-flash-attention --fp16-vae --auto-launch	

To enable SDPA, no argument is needed as it is the default, however it can be enabled with the following; --use-quad-cross-attention

python main.py --use-quad-cross-attention --fp16-vae --auto-launch