Installing ComfyUI (Linux & Windows)

Yushan777
3 min readOct 3, 2023

--

Manually Install ComfyUI on Linux or Windows

I’ve had this left unpublished for a while so I thought I’d share it for anyone who might be new to it. I am aware that there is an easy-to-install, portable Windows version but this guide will cover the manual install.

Pre-requisites

Python 3.10
Git

Step 1 : Clone the repo

Open a command prompt (Windows) or terminal (Linux) to where you would like to install the repo. We will create a folder named ai in the root directory of the C drive under Windows and in the user’s home directory under Linux.

Windows
Linux

Clone the repo using Git. When that is done set the current working directory to ComfyUI.

git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
Windows
Linux

Step 2 : Create the Virtual Environment

Next we will create the virtual environment (venv). At the time of writing the installation instructions in the repo suggest to install dependencies on a system-wide level, but it’s better (in my opinion) to keep things such as dependencies contained inside its own venv to isolate them from other projects to avoid potential conflicts. We will use the command :

python -m venv name to create a new venv. We will name the venv venv just to keep things simple.

REM: For Windows

REM: create the venv
python -m venv venv

REM: activate the venv
venv\Scripts\activate.bat
# For Linux

# create the venv (note: it is python3)
python3 -m venv venv

# activate the venv
source venv/bin/activate

When the prompt is prefixed with (venv) then it means it is active.

With the venv active, any python packages that is installed only does so within the venv.

Step 3: Install Dependencies

First, install Torch. This will take a few minutes.


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

Next, install the remaining dependencies listed in the requirements.txt file:

pip install -r requirements.txt

Step 4: Running ComfyUI

To run ComfyUI, you first to ensure that the venv is active

REM: Windows

REM: activate the venv
venv\Scripts\activate.bat

REM: start comfyui
python main.py
# Linux

# activate the venv
source venv/bin/activate

# start comfyui
python3 main.py

To make things easier, you can put both of the above inside a batch file (Windows) or a shell script (Linux).

For Windows : Create a new text file and name it launch.bat. Inside, put the following:

REM: activate the venv
call venv\Scripts\activate.bat

REM: start comfyui
python main.py --listen

Save the file, and you can simply start ComfyUI by double clicking on the launch.bat file.

For Linux: Create a new text file and name it launch.sh. Inside, put the following:

#!/bin/bash

# activate the venv
source venv/bin/activate

# start comfyui
python3 main.py

Save the file. Next we need to make the file executable with the command:

chmod +x launch.sh

To run it, simply type:

./launch.sh

Alternatively you can probably run it directly from the GUI but this will vary between different file managers.

--

--

Yushan777

No Click-Baity stuff! This is just my own journal so I can remember how I did stuff 🙂