Install (upgrade) Stable Diffusion XL [SDXL1.0]

The other day I installed WSL2 on an old Windows PC, selected Ubuntu as the OS, and installed Docker and Docker Compose on the Ubuntu itself. I installed the Docker version of StableDiffusionWebUI in that environment and tested generating images.

Today I installed Ubuntu Desktop on this PC so I can launch the Docker version of the Stable Diffusion Web UI container. Then upgrade to SDXL. This Ubuntu is not a virtual environment as I installed it on a real machine, Docker and Docker Compose are already installed.

I used the following GitHub for the Docker version of Stable Diffusion Web UI.

https://github.com/AbdBarho/stable-diffusion-webui-docker

How to install Stable Diffusion Web UI (Ubuntu)

Prerequisites: Docker and Docker Compose must be installed.

The reason for using Docker is to avoid the hassle of dependencies and to be able to use images that have been verified to work properly.

1. Cloning the project

First, clone the repository of the Docker image containing Stable Diffusion Web UI. This will download the necessary files to your local environment.

git clone https://github.com/AbdBarho/stable-diffusion-webui-docker.git

2. Building the Docker image

Next, build the Docker image in the downloaded project.

cd "directory created by the git command"
docker compose --profile download up --build

3. Start the container

If the above command succeeds, launch the Docker container. The Web UI will then be available.

docker compose --profile auto up --build

Note: This procedure can also be performed using Windows Subsystem for Linux (WSL) on Windows.

Errors during container startup and how to deal with them

Error description:

Error response from daemon: could not select device driver “nvidia” with capabilities: [[compute utility]]

This PC is old, but it had a GTX 1060 graphics card.

This error occurs because Docker cannot recognize the NVIDIA GPU. Specifically, this may be because the NVIDIA container toolkit is not installed.

Solution

  1. Attempt to install NVIDIA ‘s Container Toolkit First, try to install NVIDIA’s Container Toolkit with the following command
sudo apt install nvidia-container-toolkit

However, you may get the following error

E: Package nvidia-container-toolkit not found

This error occurs because the corresponding package does not exist in the repository. After some research, we found a way to describe the repository on the Internet.

  1. Adding the official NVIDIA repository To address the error, add the official NVIDIA repository to your system. Execute the following command
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
      && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
      && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
            sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
            sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
  1. Re-install Once the repository has been added, attempt to update and install the package again.
sudo apt update
sudo apt install nvidia-container-toolkit
  1. Restart Docker Restart Docker to make it aware of the new toolkit.
sudo service docker restart
  1. Restart the container Start the container again with the following command
docker compose --profile auto up --build

I used this method to avoid the error.

Access with a browser

Check with a browser. If you are on the same PC, enter the following address

http://localhost:7860

Download and install Stable Diffusion model (SDXL 1.0)

https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0

The file extension of the downloaded file was .safetensors. Move this file to the following directory:
project (stable-diffusion-webui-docker) → data → models → Stable-diffusion
This directory contains the initial model files, which have the .ckpt extension.

I was usually used to commands in the cloud, but when I tried to drag and drop, I couldn’t do it. I used the sudo mv command in the terminal to move it. If you want to drag and drop, change the ownership of the models directory. Initially you are root.

Example: Enter the following command while you are in the data directory

sudo chown -R mamushi:mamushi models

Press the refresh button in your browser to see the models.

Trying out different models

I am a novice when it comes to image generation, but I created images by modifying models and prompts (spells) recommended by internet searches.

Please share if you like it!
TOC