Installing Automatic1111 on Linux

How to install the Automatic1111 Stable Diffusion Webui and start generating images! This guide assumes you have an Nvidia GPU and Linux. We have a 4090 AI discord community, if you're lucky enough to have one, come say hi! https://discord.gg/zVAvFp3wnU

If you're on Windows, @GuruVirus wrote a great guide for you here: https://rentry.org/31337

This guide has been streamlined significantly since I started it, as advances in tech have made it easier to get a1111 up and running! Great stuff.

I'm going to give instructions for Ubuntu's apt, if you use a different package manager please adjust accordingly.

Dependencies

Do you have python 3.10.6 or higher installed?

python3 --version

If not, maybe it's time to upgrade to the latest version of your Linux distro. You need to install Nvidia drivers, git and some python packages:

sudo apt install --yes nvidia-driver-530 git python3-venv python3-dev

Replacing "530" with whatever the latest version is. For Windows, download and install from here: https://www.nvidia.co.uk/Download/index.aspx. Also install git from here: https://git-scm.com/download/win.

Install CUDA 12.1 by following these instructions: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html

Then reboot.

Installing Automatic1111's WebUI

Let's pull down the latest version of the webui:

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

Let's aim to move our data out of the repo so that we can reinstall easily in future. We'll use a symlink, to make sure we don't get any permission errors with extensions:

mkdir ~/stable-diffusion-data
ln -s ~/stable-diffusion-data data

We need to enter the webui's virtual environment and find out the latest version of torch 2 with CUDA support.

source venv/bin/activate
pip install torch== --index-url https://download.pytorch.org/whl/nightly/cu121

It will output a list of available versions. We want to install the latest one:

pip install torch==<insert the latest version here> torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu121

Also, we need to install xformers:

pip install -U xformers

Edit the webui-user.sh file and add "--xformers --data-dir data" to COMMANDLINE_ARGS.

Then run the webui:

./webui.sh

It should install some stuff. It will download the SD v1.5 ema only model (to ~/stable-diffusion-data/models/) for you to get started.

Test Your Speed

Use the 1200 Test to measure your speed:

4090 Grotto

You should be getting at least 40 it/s on a 4090.

Join us at the 4090 Grotto on discord and tell us your 1200 test results! https://discord.gg/zVAvFp3wnU
You'll find resources and support from a friendly community of 4090 owners.

Have fun! -Mad

Maintenance

Whenever you mess about with pip packages, make sure you're in the webui's venv. The venv is a python virtual environment that the webui uses to keep any changes to python packages local to the webui.

cd ~/stable-diffusion-webui
source venv/bin/activate

All python packages will be installed within the venv folder. This means that as long as you backup your webui folder, if you make any changes that mess things up then all you need to do is revert to the backup to get back to a working system.

Mistakes

Are there any mistakes in this guide, or improvements you can suggest? Let me know on discord, https://discord.gg/zVAvFp3wnU

-Mad

Edit Report
Pub: 18 Apr 2023 20:11 UTC
Edit: 09 Oct 2023 15:08 UTC
Views: 5647