- AI
- A
Stable Diffusion + ComfyUI Installation
In this article, I would like to share a guide on installing Stable Diffusion and ComfyUI.
Disclaimer
I am writing this article as a tutorial for myself (in case I need to reinstall) and for friends. Of course, all of this can be googled, but I've just done all that—googled, chatgpt'ed, and collected the results into a single guide. Maybe it'll be useful to someone.
I'm not an experienced AI user, this is my first time installing and using one, but it might be helpful since I hit some common snags and found a working solution. Tips and corrections are welcome.
Preparation
My setup: OS: Linux Mint 22 x86_64, GPU: NVIDIA 5070 Ti, NVIDIA driver 570.153.02 installed.
First, check that Python ≥ 3.9 is installed:
python3 --version
and install the necessary packages:
sudo apt update
sudo apt install python3-pip python3-venv git cmake xdg-utils
Check that the GPU works correctly with the command:
$ nvidia-smi
Sat Jun 21 11:07:37 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.153.02 Driver Version: 570.153.02 CUDA Version: 12.8 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 5070 Ti Off | 00000000:01:00.0 On | N/A |
| 0% 51C P5 34W / 300W | 1443MiB / 16303MiB | 21% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
We need to make sure CUDA is displayed and the device is detected.
Installation
Next, we’ll install everything using Comfy CLI, which, as far as I understand, is the recommended method.
Create and activate a virtual environment:
python3 -m venv comfy-env
source comfy-env/bin/activate
Install Comfy CLI:
pip install comfy-cli
Install ComfyUI itself
comfy install
Install PyTorch with CUDA support
It’s important to pick the right index URL for your CUDA. I followed ChatGPT’s advice and installed the wrong version at first, so nothing worked. For CUDA Version: 12.8, here’s the correct one:
pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128
Found this solution here https://github.com/comfyanonymous/ComfyUI/issues/7127#issuecomment-2746096337
Check the GPU in Python, after making sure you’re using the correct environment
$ which python
/comfy-env/bin/python
$ python
Python 3.12.3 (main, May 26 2025, 18:50:19) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
True
>>> print(torch.version.cuda)
12.8
>>>
Download Stable Diffusion models
comfy model download --url --relative-path models/checkpoints
I immediately installed sd_xl_base_1.0.safetensors and sd_xl_refiner_1.0.safetensors. I’ll write later about what the refiner is for and how to use it—still tinkering with it, and haven’t finished my notes on that.
Run ComfyUI
comfy launch
In the browser, go here:
http://localhost:8188
Pick a basic image generation workflow template, select the downloaded model, make sure everything works:
However, it’ll only work until the first reboot, which isn’t ideal. We’ll fix that.
Systemd service for ComfyUI
Creating the service
sudo vim /etc/systemd/system/comfyui.service
with the following content:
[Unit]
Description=ComfyUI Stable Diffusion Server
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=
WorkingDirectory=/comfy/ComfyUi
ExecStart=/comfy/start-comfyui.sh
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Creating the script start-comfyui.sh
#!/bin/bash
source /comfy-env/bin/activate
cd /comfy/ComfyUi
exec python main.py --listen 0.0.0.0
Make it executable
chmod +x ~/comfy/start-comfyui.sh
Activate the service
sudo systemctl daemon-reload
sudo systemctl enable comfyui
sudo systemctl start comfyui
and check that everything is working
$ systemctl status comfyui
● comfyui.service - ComfyUI Stable Diffusion Server
Loaded: loaded (/etc/systemd/system/comfyui.service; enabled; preset: enabled)
Active: active (running) since Tue 2025-06-17 15:12:03 CST; 3 days ago
Main PID: 2127 (python)
Tasks: 63 (limit: 76101)
Memory: 16.4G (peak: 16.8G swap: 91.5M swap peak: 177.9M)
CPU: 4min 5.076s
CGroup: /system.slice/comfyui.service
└─2127 python main.py --listen 0.0.0.0
By default, ComfyUI runs on port 8188, you can change it by specifying the --port
parameter.
If something goes wrong after a reboot or anything else doesn’t go as planned
Check that the service is alive:
systemctl is-active comfyui
and view the latest logs, for example, like this:
journalctl -u comfyui --since "15 minutes ago"
That's all for now. I'm always open to feedback, clarifications, and suggestions.
Write comment