Skip to main content

Stable Diffusion Guide

· 2 min read
Max Kaido
Architect

Ohhh yesss Max, let’s melt some pixels. Here's your no-bullshit, GPU-blazing Stable Diffusion install guide for Ubuntu 24 + RTX 3060. We’re going full AUTOMATIC1111 web UI with xformers, half-precision, and stable CUDA.

⚙️ Part 1: System Prep

🧼 Clean up first (if needed)

sudo apt update && sudo apt upgrade -y
sudo apt install -y build-essential git curl wget python3 python3-venv python3-pip

🔥 Part 2: NVIDIA Drivers + CUDA

Check your driver:

nvidia-smi

Should show your 3060 and a driver ≥ 525

If not:

sudo ubuntu-drivers devices
sudo apt install nvidia-driver-535 -y
reboot

Install matching CUDA + cuDNN (optional but good for other projects)

We’ll rely on PyTorch’s bundled CUDA later, so skip full CUDA toolkit unless you want TensorCore development.


🧠 Part 3: Install PyTorch (with CUDA 11.8)

Use pip inside a venv

python3 -m venv sdwebui
source sdwebui/bin/activate
pip install --upgrade pip

Then install torch + torchvision:

pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118

🖼️ Part 4: Clone AUTOMATIC1111 Web UI

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui

💽 Part 5: Drop your model

Download a model like SD 1.5 and drop it here:

cd stable-diffusion-webui/models/Stable-diffusion
# Example
wget https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors

⚙️ Part 6: Optimize it

Edit webui-user.sh (or webui-user.bat if on Windows):

nano webui-user.sh

And add:

export TORCH_COMMAND="pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118"
export COMMANDLINE_ARGS="--xformers --medvram --opt-sdp-attention"

--xformers = fast, optimized memory ✅ --medvram = lets it run smoother on 12GB ✅ --opt-sdp-attention = newer attention backend, fast & clean


🚀 Part 7: Launch it

./webui.sh

It'll auto-install everything in venv, then serve it at:

http://127.0.0.1:7860


💎 Optional Enhancements

ControlNet

# Put models in:
stable-diffusion-webui/extensions/sd-webui-controlnet/models

LoRA / embeddings / training

You’ve got 12GB VRAM — LoRA training is totally viable.


🧠 Test prompt

a neon cyberpunk girl with glowing eyes, ultra detailed, cinematic lighting

You want a script to automate the whole thing? Or a headless/remote version with tmux and ngrok? I got you.