Now I have reached a point in the use of Automatic1111 that I also go a little deeper into the configuration. At the beginning I had passed parameters at the start of the software like listen or port. But there are much more possibilities to configure the own hardware with Automatic1111. The configurations I have tried myself are described in detail below.

Multi-GPU Configuration

If you have several NVIDIA GPUs installed in your system, you can specify on which of the GPUs the processes for generating the images should run.

Note: It is important to understand that a generation process cannot be split between multiple GPUs. That means a job runs on one GPU and is not multi GPU capable.

The configuration I describe here for Linux or for Ubuntu but also under Windows there are the same settings but then just in the corresponding *.bat file and not *.sh file.

Under Ubuntu go to the installation path of Automatic1111 and open the file In this file you look for the line #export COMMANDLINE_ARGS="". This line you change e.g. as follows that the calculation job of Automatic1111 runs on the GPU 1 if you have two graphic cards in your system. With me as two graphic cards you simply count up. In the following picture I added two yellow arrows to show you how to get the GPU ID. The numbering starts with 0, 1, 2, 3, etc.

The adjusted line for GPU 1 looks like this: export COMMANDLINE_ARGS="--device-id=1".

In the following picture you can see that the job for generating the images is running on GPU 1.

Automatic1111 Stable Diffusion multi GPU configuration

Automatic1111 Stable Diffusion multi GPU configuration

Note: I had problems when I ran multiple jobs on GPU 1 that PyTorch did not free the memory anymore. I had not noticed this when the GPU 0 is used so the default setting. I did not investigate further why and why the behavior is so.

Start automatically

Because I don’t want to log in to the PC to start Automatic1111 I wrote a small shell script which does exactly this startup for me. To do this, please create the following start script on the computer in a folder with e.g. the name scripts. In this folder now put a file with the name Following now the commands for the terminal.

Command: mkdir ~/script

Command: cd ~/script

Command: nano

Note: In the following section, please make sure that you replace <user_name> with your username of the Linux system. Otherwise the start script will not work.

Now the following lines must be inserted into the script

# Autor: Ingmar Stapel
# Date: 20230501
# This script starts Automatic1111 in an Anaconda virtual environment

source /home/<user_name>/anaconda3/bin/activate stable-diffusion >> /home/<user_name>/stable-diffusion-anaconda.log 2>&1 &
sleep 1
bash /home/<user_name>/stable-diffusion-webui/ --listen --port 7860 >> /home/<user_name>/stable-diffusion-webui.log 2>&1 &

Then save the file and change the file permissions so that it can be executed.

Command: chmod +x

Now an entry must be made in the crontab so that the script is also executed after each restart. To do this, simply open the crontab once with the following command.

Command: sudo nano /etc/crontab

Now insert the following line to allow the script.

@reboot <user_name> /usr/bin/bash /home/<user_name>/ >> /home/<user_name>/stable-diffusion-crontab.log 2>&1 &

If you restart the computer now, Automatic1111 should start automatically. If this is not the case, then you can read in the two log files which are created once by the start script and once by the crontab process. You can find these two log files in the user directory on your system with the names stable-diffusion-webui.log and stable-diffusion-crontab.log.


Artikelübersicht - Stable Diffusion:

Stable Diffusion - AUTOMATIC1111 Ubuntu Installation Teil 1/2
Stable Diffusion - AUTOMATIC1111 Ubuntu Installation Teil 2/2
Stable Diffusion - Bilder lokal generieren mit Prompt Beispielen
Stable Diffusion - AUTOMATIC1111 Experten Konfiguration
Stable Diffusion - Dreambooth Training Finetuning einrichten Teil 1/2
Stable Diffusion - Dreambooth Training Finetuning ausführen Teil 2/2