Guide: Self-hosting Stable Diffusion on Ubuntu using an Nvidia GPU

This guide is for self-hosting Stable Diffusion on an Nvidia GPU with >=8GB of VRAM.

Hardware recommendations

The following is strictly my opinion at time of writing…

Ampere series (latest) GPUs are the most recommended for both cost and features but Turing, Volta, Pascal and Maxwell series GPUs should all work. See: cuda support

Cheapest recommendation: Nvidia Quadro P4000 8GB (i’ve confirmed it works with this guide)
Best all-rounder and value for money: Nvidia RTX 3060 12GB (i’ve confirmed it works with this guide)
Best consumer card: Nvidia RTX 3060 16GB (or 4090 16GB when avail.)

While it’s possible to run Stable Diffusion on AMD GPUs and GPU’s with 4GB of RAM but it’s complicated and not recommended.


Install and confirm the presence of an Nvidia card

Follow this guide to install nvidia drivers:

# Install the nvidia cli
sudo apt install nvidia-smi

# Confirm your card(s) are recognized

# Reboot

# Note: If nvidia drivers are included in an update the OS must be reset to using Stable Diffusion

Install stable-diffusion-webui

sudo apt install git pip wget python3 python3-venv -y

# Download and initalize the stable-diffusion cloud install package
cd $HOME
git clone

# Optional: localize the python env directory for portability
python3 -m venv $HOME/stable-diffusion-webui/venv/
source $HOME/stable-diffusion-webui/venv/bin/activate # <== Note: needs to be run every new shell session

# Optional: Download models (highly recommended)
cd $HOME/stable-diffusion-webui/models/Stable-diffusion
wget -c
wget -c

# Optional: Download a VAE (highly recommended)
cd $HOME/stable-diffusion-webui/models/VAE
wget -c

# Pre-download upscaler models
cd $HOME/stable-diffusion-webui/models/ESRGAN/
wget -c
cd $HOME/stable-diffusion-webui/models/RealESRGAN/
wget -c

# Optional: Download embeds for prompt enhancement (highly recommended)
cd $HOME/stable-diffusion-webui/embeddings
wget -c
wget -c
wget -c
wget -c

# Start the webui which will pull in remaining dependencies
# Note: This will take a long time and if things break it'll be here, see: Resolving errors
# If successful, it'll stay open with "Running on local URL:"
bash $HOME/stable-diffusion-webui/

Resolving errors (if any)

# Cloning Taming Transformers
	# For error: "error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function."
		cd $HOME/stable-diffusion-webui/
		git config --global http.postBuffer 1048576000

# If internet is unstable, loop installation till it completes
	while ! bash $HOME/stable-diffusion-webui/; do sleep 1; done

# In another terminal, test if the site is up

GUI Configuration

Open a browser and go to:

Enable the VAE:

  1. On the top bar, click “Settings”
  2. On the side bar, click “Stable Diffusion”
  3. Click the “SD VAE” dropdown and choose: vae-ft-mse-840000-ema-pruned.ckpt
  4. Click “Apply settings”

Privacy/Security note

The web interface uses CSS from and a script from These online dependencies can be removed by downloading and localizing the references. I’ll write a script to do this automatically if there’s demand.

Using Stable Diffusion

Renders are stored in: $HOME/stable-diffusion/outputs/

Example Prompt

AI model: revAnimated_v11.safetensors
Sampling: Euler a
CFG Scale: 6
Pixel range: 1080x720

Positive Prompt

((best quality)), ((masterpiece)), ((realistic)), (detailed), (cyberpunk), (Ferrari), race cars, blender, intricate background, intricate buildings, ((masterpiece)), HDR

Negative prompt

(semi-realistic:1.4), (worst quality, low quality:1.3), (depth of field, blurry:1.2), (greyscale, monochrome:1.1), nose, cropped, lowres, text, jpeg artifacts, signature, watermark, username, blurry, artist name, trademark, watermark, title, multiple view, Reference sheet

Example renders:


Any idea if this would work in a Ubuntu image ran through distrobox with Fedora as the host?

Thanks for the tutorial. Good work!

1 Like

If you run nvidia-smi in the environment you plan to use and it shows your Nvidia card, the rest of the guide should work.

I listed it as an Ubuntu guide (and i’ll be adding Debian) because they have 1st-class Nvidia support and having burned a day getting things 1/2 working on Fedora i’d need to deep dive it more.

1 Like

Pop!_OS also has Nvidia support out of the box when you use the correct ISO.

Here’s my stable defusion running on my machine and with finding the right model I can have it draw a field :smiley: its pretty dope stuff esp for inspiration


Nevermind, just saw that Pop_OS wasn’t one of the compatible distros.