How to install Stable Diffusion ComfyUI
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.
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.
ComfyUI_windows_portable_nvidia.7z
Link.
\ComfyUI_windows_portable\ComfyUI\models\checkpoints
. If you do not have a model, download “v1-5-pruned-emaonly.safetensors”.
\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
cd %userprofile%
git clone https://github.com/comfyanonymous/ComfyUI.git
\ComfyUI_windows_portable\ComfyUI\models\checkpoints
.
\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 openextra_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.
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.