DCAI
Loading Light/Dark Toggl

How to install Stable Diffusion ComfyUI

⏱️13min read
📅 Jul 09, 2024
🔄 Aug 09, 2024
How to install Stable Diffusion ComfyUI featured Image
Supported by

This article introduces how to install ComfyUI, the UI for Stable Diffusion, which may seem more difficult to use than Automatic1111 WebUI, but once you get used to it, you can create complex configurations intuitively and with no code. It is also useful for studying programming because you can visualize the process of creating a Stable Diffusion.

PR
Image of ASUS TUF Gaming GeForce RTX 4090 24GB Gaming Graphics Card (DLSS 3, PCIe 4.0, 24GB GDDR6X, HDMI 2.1a, DisplayPort 1.4a, TUF-RTX4090-24G-GAMING)
ASUS TUF Gaming GeForce RTX 4090 24GB Gaming Graphics Card (DLSS 3, PCIe 4.0, 24GB GDDR6X, HDMI 2.1a, DisplayPort 1.4a, TUF-RTX4090-24G-GAMING)
🔗Amazon-Usa Link
Image of MSI Gaming RTX 4070 Ti Super 16G Gaming X Slim Graphics Card (NVIDIA RTX 4070 Ti Super, 256-Bit, Extreme Clock: 2685 MHz, 16GB GDRR6X 21 Gbps, HDMI/DP, Ada Lovelace Architecture)
MSI Gaming RTX 4070 Ti Super 16G Gaming X Slim Graphics Card (NVIDIA RTX 4070 Ti Super, 256-Bit, Extreme Clock: 2685 MHz, 16GB GDRR6X 21 Gbps, HDMI/DP, Ada Lovelace Architecture)
🔗Amazon-Usa Link

What is ComfyUI?

“ComfyUI” is a node-based GUI for Stable Diffusion. Node-based GUI is a graphic user interface in which blocks with various functions are connected by strings. It is also used in 3DCG Houdini, game engine UnrealEngine, visual programming vvvv, touch Designer, etc.

It supports SD1.x, SD2.x, SDXL, Stable Video Diffusion, Stable Cascade, SD3, and Stable Audio, which means that most of the Stable Diffusion technologies can be used. In addition, “Smart Memory Management” allows for operation with as little as 1GB of VRAM.

How to install ComfyUI

There are two ways to install “ComfyUI”. One is to download and install the “Portable Standalone Build” (Windows only) and the other is to install manually (Windows and Linux). We recommend the former method as it is very simple and easy.

How to install using a portable stand-alone build

This is very easy to do, just download the build from the official Github release page and unzip it.

Download Build: Go to the official release page and download the file from the ComfyUI_windows_portable_nvidia.7z Link.
Unzip the downloaded file: The downloaded file is compressed with 🔗7-zip, so use a decompression proclaimer that supports 7z files to decompress it to the desired location.
Model Installation: Place your favorite models in \ComfyUI_windows_portable\ComfyUI\models\checkpoints. If you do not have a model, download “v1-5-pruned-emaonly.safetensors”.
VAE Installation: Place your favorite VAE in \ComfyUI_windows_portable\ComfyUI\models\vae. If you don’t have this one, download “vae-ft-mse-840000-ema-pruned”.

These steps will complete the installation.

Please refer to the separate introductions for SD1.5, SDXL1.0 and VAE regarding models. If you are using Automatic1111 WebUI and want to share models, please refer to 🔗How to share Automatic1111 WebUI models with ComfyUI

Manual Installation Method

This method is not recommended because it requires manual operation for everything from installation to startup. Linux users can only install the software in this way, but Windows users are recommended to use the stand-alone method.

The following programs are required for manual installation.

  • Python 3.10
  • Git
Preparation of clones: Open a command prompt and use the following command to navigate to your home folder (e.g. C:\Users\your user name) *You may set it to any location of your choice.
cd %userprofile%
Clone Repository: Next, run the following command to clone the ComfyUI repository. When the clone is finished, close the command prompt with an x.
git clone https://github.com/comfyanonymous/ComfyUI.git
Model Installation: Place the model of your choice in \ComfyUI_windows_portable\ComfyUI\models\checkpoints.
VAE Installation: Place the VAE of your choice in \ComfyUI_windows_portable\ComfyUI\models\vae.

From here, you will move on to the next step, which will vary depending on your GPU, so follow your GPU.

NVIDIA

If you are using NVIDIA GPU, install “pytorch” with the following command. *If the version of “pip” is old and an error occurs, run the command python.exe -m pip install --upgrade pip to upgrade.

pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121

Also, if you want to use a nightly build of pytorch to increase performance as much as possible, install it with the following command.

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

AMD (Linux only)

If you are using an AMD GPU, which is not officially supported, install “rocm” and “pytorch” with the following commands.

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

If you want to use rocm’s nightly builds to improve performance as much as possible, use the following command to install rocm.

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

If you get a “Torch not compiled with CUDA enabled” error, uninstall “torch” using pip uninstall torch and then install it again using the above command.

Requirements installation

Use cd ComfyUI to navigate the directory and install the required components with the following command.

pip install -r requirements.txt

Once the installation of the required components is complete, the installation is finished. Finally, create a Batch file for startup.

Creation of startup files (Windows)

  • Create a new text file in the ComfyUI directory.
  • Rename the file run_comfyui.bat or something similar.
  • The code contents are as follows
    @echo off
    python ./main.py
    pause

Launch ComfyUI and check operation

Note that the method of starting ComfyUI is also different between standalone and manual installation.

Startup method of Standalone

Run the file run_nvidia_gpu.bat in the unzipped folder, a browser will open after a while.

Startup method of Manual Installation

For manual installation, run the startup Batch file created during installation.

  • Execute run_comfyui.bat.
  • After a few moments, the console will display Starting server To see the GUI go to: http://127.0.0.1:8188, Ctrl + click to open the browser.

For Linux users, open ComfyUI in a console and start it with python main.py.

Confirmation of Operation

To check the operation, press the “Queue Prompt” button in the menu. If there are no errors, the image will be generated. If there is an error, the node with the error is marked with a red frame, so you should fix the problem in that area. Remember to reselect v1-5-pruned-emaonly.ckpt as the default workflow checkpoint model of ComfyUI, so re-select v1-5-pruned-emaonly.safetensors.

How to exit ComfyUI

ComfyUI, like Automatic1111 WebUI, does not terminate simply by closing the browser. To terminate the process, open a command prompt, hold down the Ctrl key and press C, and when prompted to exit, type Y and press Enter.

How to share Automatic1111 WebUI models with ComfyUI

If you already have Automatic1111 WebUI installed on your PC, we recommend that you share models and other data so that you do not need to have multiple large models such as checkpoint models, which can overwhelm storage space.

  • Edit extra_model_paths.yaml.example: Open \ComfyUI_windows_portable\ComfyUI\ in File Explorer and open extra_model_paths.yaml.example in a text editor.
  • Enter the BasePath of the A1111 WebUI: Enter the absolute (full) path to A1111WebUI in base_path: path/to/stable-diffusion-webui/ around line 7.
    e.g.: 
    base_path: C:/Users/USER-NAME/stable-diffusion-webui/
  • Rename and save the file: Rename the file to extra_model_paths.yaml and save it.
  • Confirmation of models: After starting ComfyUI, check that the checkpoint model has been successfully loaded. If not, check if the base path and file name are set correctly.

In this way the following models are shared

  • Checkpoints
  • Configs (checkpoints)
  • VAE
  • LoRAs
  • Upscale_models
  • Embeddings
  • Hypernetworks
  • controlnet

How to uninstall ComfyUI

Standalone users can uninstall by deleting the ComfyUI_windows_portable folder.

Manual installers can uninstall the ComfyUI folder by removing it. If you want to uninstall it completely, you should also uninstall Python.

Note: When deleting, model data in the folder will also be deleted, so if you are considering reinstalling and have not shared models, we recommend making a backup.

How to backup ComfyUI

For standalone users, copy the ComfyUI_windows_portable folder.

For manual installers, copy the ComfyUI folder and you are done.

If you want to minimize this, back up the following folders in the ComfyUI folder.

  • models: Model data are stored.
  • custom_nodes: Custom nodes (extensions) are stored.

Conclusion

How was it? In this article, we have shown you how to install ComfyUI. We recommend Windows users to install the portable version, as it is quite simple to install. This article is the first in a series of Generate AI Intermediate articles. In the Intermediate level, we would like to focus the article on ComfyUI. In the next article, we will explain how to use ComfyUI. Thank you for reading to the end.

PR
Image of Intel® CoreTM i9-14900K New Gaming Desktop Processor 24 (8 P-cores + 16 E-cores) with Integrated Graphics - Unlocked
Intel® CoreTM i9-14900K New Gaming Desktop Processor 24 (8 P-cores + 16 E-cores) with Integrated Graphics - Unlocked
🔗Amazon-Usa Link
Image of Corsair RM1000x Shift Fully Modular ATX Power Supply - Modular Side Interface - ATX 3.0 & PCIe 5.0 Compliant - Zero RPM Fan Mode - 105°C-Rated Capacitors - 80 Plus Gold Efficiency - Black
Corsair RM1000x Shift Fully Modular ATX Power Supply - Modular Side Interface - ATX 3.0 & PCIe 5.0 Compliant - Zero RPM Fan Mode - 105°C-Rated Capacitors - 80 Plus Gold Efficiency - Black
🔗Amazon-Usa Link
Supported by