Stable Diffusion runs fine on your own Linux box with an NVIDIA GPU. No cloud subscription, no per-image credits, no queue. This guide installs it end to end on Ubuntu and on Rocky/RHEL, generates real images, and shows the generation times and VRAM you should actually expect. Every command here was run on an RTX 4090 in September 2026, and the RHEL package and ComfyUI install steps were validated on Rocky Linux 10.
We build this on ComfyUI, not AUTOMATIC1111. That choice matters now, so here is the reasoning before you type anything.
ComfyUI or AUTOMATIC1111?
Most older tutorials install the AUTOMATIC1111 web UI. It still works, but active development has stalled and it cannot run Flux, the model family that now sets the quality bar for local generation. ComfyUI is the maintained default. It picks up new model architectures first, runs faster, and uses less VRAM on the same card.
| ComfyUI | AUTOMATIC1111 | |
|---|---|---|
| Active development | Yes, frequent releases | Stalled |
| SDXL / SD 3.5 | Both | SDXL only |
| Flux.1 | Yes | No |
| Speed on the same GPU | Faster | Slower |
| VRAM use | Lower | Higher |
| Interface | Node graph | Form and tabs |
The node graph has a learning curve, but it ships with ready-made workflows, so you generate your first image without wiring a single node yourself. If you specifically want the form-style AUTOMATIC1111 interface, the driver and Python steps below still apply. Only the final clone and launch differ.
What you need
Stable Diffusion is GPU bound. An NVIDIA card with enough VRAM is the one hard requirement. CPU generation technically works and is unusably slow, so this guide assumes a GPU. VRAM is what decides which models you can run:
| VRAM | What runs comfortably |
|---|---|
| 8 GB | SD 1.5 and SDXL at 1024px with memory-saving flags |
| 12 GB | SDXL comfortably, Flux in fp8 with offloading |
| 16 GB | SDXL and SD 3.5, Flux fp8 with little offloading |
| 24 GB and up | Everything here at full speed, room for larger batches |
No local GPU? You can rent one by the hour. We ran this entire build on a single RTX 4090 rented from vast.ai for well under a dollar an hour, which is the cheapest way to follow along if your workstation has no NVIDIA card. If you rent GPUs often, it pays to script the rent-and-destroy cycle so you never leave one running idle. If you are weighing a card to buy, our GPU picks for local AI break down the VRAM-per-dollar tradeoffs.
Budget about 30 GB of free disk for the two models we download, plus room for your outputs.
Install the NVIDIA driver
ComfyUI runs on PyTorch, and the PyTorch pip wheel bundles its own CUDA runtime. You need the NVIDIA driver so the GPU is visible, but you do not need the full CUDA Toolkit that older guides tell you to install. Skip nvcc unless you compile CUDA code yourself.
On Ubuntu 26.04 or 24.04, the packaged driver is the simplest path. Server and cloud images do not ship the helper, so install it first:
sudo apt update
sudo apt install -y ubuntu-drivers-common
sudo ubuntu-drivers install
If you want a specific driver branch, use NVIDIA’s own repository instead. Add the CUDA repo key and install the driver metapackage. Swap ubuntu2404 for ubuntu2604 on 26.04:
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt update
sudo apt install -y cuda-drivers
On Rocky Linux, AlmaLinux, or RHEL 10, the driver builds a kernel module, so install the prerequisites first: EPEL and CRB for the dependencies, the compiler toolchain, and kernel headers matched to the running kernel.
sudo dnf install -y epel-release
sudo dnf config-manager --set-enabled crb
sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y kernel-devel-matched kernel-headers
Those first two lines are the Rocky and AlmaLinux form. On subscription-based RHEL, install EPEL from the Fedora project RPM and enable CodeReady Builder with subscription-manager repos --enable codeready-builder-for-rhel-10-x86_64-rpms instead.
Now add the NVIDIA CUDA repository for EL10 and install the driver metapackage:
sudo dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel10/x86_64/cuda-rhel10.repo
sudo dnf clean all
sudo dnf -y install cuda-drivers
Reboot after the driver installs so the kernel module loads, then confirm the GPU is visible:
nvidia-smi
You should see the card, its total memory, and the driver version in the header:
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 580.159.03 Driver Version: 580.159.03 CUDA Version: 13.0 |
+-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| 0 NVIDIA GeForce RTX 4090 On | 00000000:C2:00.0 Off | Off |
| 30% 40C P8 28W / 450W | 1MiB / 24564MiB | 0% Default |
+-----------------------------------------+------------------------+----------------------+
If nvidia-smi reports “command not found” or “no devices were found”, the module did not load. On RHEL that usually means Secure Boot rejected the unsigned module, so either enroll the key it prompts for or turn Secure Boot off in firmware. Our longer walk-through covers the details in installing NVIDIA drivers and CUDA on Ubuntu.
Install ComfyUI
ComfyUI is a Python application. Install Git, Python, and the tools to build a couple of wheels, then run it inside a virtual environment so it never touches your system Python.
On Ubuntu or Debian:
sudo apt update
sudo apt install -y git python3 python3-venv python3-pip
On Rocky, AlmaLinux, or RHEL, the virtual-environment module ships inside the base python3 package, so there is no separate venv package to add. You do need a compiler and the Python headers:
sudo dnf install -y git python3 python3-pip python3-devel gcc
Clone the repository into your home directory:
cd ~
git clone https://github.com/comfyanonymous/ComfyUI
cd ComfyUI
Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate
Install the CUDA build of PyTorch first, then the rest of ComfyUI’s requirements. Pinning the CUDA wheel index avoids the CPU-only build that pip sometimes selects by default:
pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
pip install -r requirements.txt
The cu128 index gives you the widest driver compatibility and is what we tested. On a very recent driver (CUDA 13), you can use the newer cu130 build that ComfyUI now favors, but cu128 runs fine on both.
Confirm PyTorch actually sees the GPU before going any further. This one line saves a lot of confusion later:
python3 -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0))"
A working install prints True and the GPU name:
True NVIDIA GeForce RTX 4090
Here is that check together with the driver confirmation on our test box:

With the driver and PyTorch both working, ComfyUI has everything it needs to run. Next come the models.
Download the models
ComfyUI ships no models. You download the checkpoints yourself and drop them into models/checkpoints. We use two: SDXL, the Stable Diffusion baseline that still holds up, and Flux.1 schnell, a sharper model that ComfyUI runs and AUTOMATIC1111 cannot.
Grab SDXL base first. It is about 6.9 GB:
cd ~/ComfyUI/models/checkpoints
wget https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors
Then the all-in-one fp8 build of Flux.1 schnell. It packs the text encoders and VAE into a single file, so there are no extra downloads to chase. It is Apache-2.0 licensed and needs no account, unlike the gated Flux dev and SD 3.5 weights:
wget https://huggingface.co/Comfy-Org/flux1-schnell/resolve/main/flux1-schnell-fp8.safetensors
Both files should now sit in the checkpoints folder:
ls -lh ~/ComfyUI/models/checkpoints
The sizes confirm the downloads completed in full. ls reports in GiB, so the 6.9 GB and 17.2 GB files show as 6.5G and 17G:
-rw-r--r-- 1 user user 6.5G sd_xl_base_1.0.safetensors
-rw-r--r-- 1 user user 17G flux1-schnell-fp8.safetensors
With both checkpoints in place, you can start the server.
Launch ComfyUI and open the web UI
Start the server. The --listen flag binds it to all interfaces so you can reach it from another machine on your network, which is what you want on a headless GPU box. On a local desktop you can drop the flag and use the default localhost bind:
cd ~/ComfyUI
source venv/bin/activate
python3 main.py --listen
The startup log reports the detected GPU, the VRAM it sees, and the address to open:
Total VRAM 24081 MB, total RAM 61747 MB
pytorch version: 2.11.0+cu128
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 4090 : cudaMallocAsync
ComfyUI version: 0.34.0
comfyui-frontend-package version: 1.51.9
Starting server
To see the GUI go to: http://0.0.0.0:8188
Open http://SERVER-IP:8188 in a browser. ComfyUI opens on a starter workflow. From the Workflow menu, load a basic text-to-image template, then set the checkpoint loader to sd_xl_base_1.0.safetensors. The graph is small and readable: a checkpoint loader, a positive and a negative prompt, an empty latent, a sampler, and a save node. This is the whole pipeline for an image.

With the workflow loaded and the checkpoint set, you are ready to generate.
Generate your first image
Type a prompt into the positive box, leave the negative box for things you want to avoid, and click Run. Our test prompt was “a photorealistic red fox sitting in a snowy pine forest at golden hour, sharp focus, detailed fur, cinematic lighting” at 1024×1024, 30 steps, the euler sampler. The result:

The very first run is slow because the checkpoint has to load from disk into VRAM, which took about 40 seconds here. Every image after that reuses the loaded model. Warm SDXL runs at these settings landed around 5.5 seconds each and peaked at roughly 9.5 GB of VRAM.
Run Flux.1 for higher quality
Flux is where local generation got good. Point the checkpoint loader at flux1-schnell-fp8.safetensors, drop the sampler to 4 steps, and set the guidance to 1.0. Schnell is tuned for four steps, so it stays fast despite being the larger model. The same prompt through Flux schnell:

The lighting, depth of field, and fur detail are a clear step up from SDXL, and it got there in four steps instead of thirty. The tradeoff is memory. Flux peaked near 19.7 GB, roughly twice SDXL, which is why the VRAM table above matters when you pick a card.
What to expect on real hardware
Here are the warm numbers from our RTX 4090, taken from ComfyUI’s own per-prompt timing. Generation time tracks step count and resolution, and VRAM tracks model size:
| Model | Resolution | Steps | Time per image | Peak VRAM |
|---|---|---|---|---|
| SDXL base | 1024×1024 | 30 | ~5.5 s | ~9.5 GB |
| Flux.1 schnell (fp8) | 1024×1024 | 4 | ~3.0 s | ~19.7 GB |
The console prints that timing after every run, which is the honest way to benchmark your own setup:

On a smaller card the models still run, they just page more between system RAM and VRAM. If you hit an out-of-memory error, restart ComfyUI with a memory-saving flag:
python3 main.py --listen --lowvram
--lowvram offloads parts of the model to system RAM, and --novram pushes that further for cards under 6 GB, both at the cost of speed. On 8 GB cards, generating at 768px instead of 1024px is the other easy win.
Keep it running
Running main.py in a terminal dies when you log out. On a box you actually use, put it behind a systemd service so it starts on boot and restarts on failure. Create the unit:
sudo vim /etc/systemd/system/comfyui.service
Point it at the venv Python and your ComfyUI directory. Replace the user and paths with yours:
[Unit]
Description=ComfyUI
After=network-online.target
Wants=network-online.target
[Service]
User=youruser
WorkingDirectory=/home/youruser/ComfyUI
ExecStart=/home/youruser/ComfyUI/venv/bin/python3 main.py --listen
Restart=on-failure
[Install]
WantedBy=multi-user.target
Enable and start it:
sudo systemctl daemon-reload
sudo systemctl enable --now comfyui
ComfyUI now survives reboots and logouts. From here the interesting work is adding models. ControlNet for pose and depth control, LoRAs for specific styles, and upscalers all drop into their folders under models and show up in the node menus. The install is the boring part, and it is done.
If you are building a local AI stack beyond image generation, the same GPU happily runs text models too. Our guides on running a local LLM with llama.cpp and Ollama on Ubuntu pick up where this one leaves off.