Install stable diffusion web ui (WSL)

Install the docker version of stable diffusion web ui. we have already installed the Windows subsystem for Linux (WSL2) and will use it to achieve this. from Microsoft Store we have installed ubuntu and have just created a user and password. passwords have just been created.

Install docker and docker compose, without which you will not be able to start. Both of them can be installed with reference to the official website. First, we will install from docker (Docker CE). docker Desktop for Windows is not necessary since it will be installed on ubuntu itself.

https://docs.docker.jp/engine/installation/linux/docker-ce/ubuntu.html

The following page was the easiest to understand. However, this article is based on the URL above.

https://docs.docker.com/engine/install/ubuntu

The first step is to update the system’s package list to the latest state. This is an important step to take before installing new packages.

sudo apt-get update

Next, install the packages needed to be able to retrieve packages from the repository via HTTPS. The packages to be installed here have the following roles

  • apt-transport-https: Required to retrieve packages via HTTPS
  • ca-certificates: Necessary to validate server certificates
  • curl: Tool to download data from the web
  • software-properties-common: Tool to add and manage software properties

Run the following commands to install them

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

Next, add the official Docker GPG key. This is a procedure to guarantee the authenticity of Docker packages.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Then add the stable version of the Docker repository to the system’s repository list. This will allow the system to retrieve Docker packages from this repository.

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

Now that the repository has been added, update the system package list again. This will reflect the package information from the Docker repository you just added to the system.

sudo apt-get update

Finally, install Docker CE (Community Edition, Community Edition). This completes the Docker setup.

sudo apt-get install docker-ce

This completes the instructions for installing Docker on an Ubuntu system. After installation, it is recommended to run the “docker --version” command to verify that Docker has been installed correctly.

Next, Docker compose is also installed. To install this one, refer to the official site and the link (github) there.

https://docs.docker.jp/v1.12/compose/install.html

https://github.com/docker/compose/releases

This section describes the installation of Docker Compose, a tool for managing multiple Docker containers that allows you to create and manage containers based on settings defined in a YAML file.

First, download the stable version of Docker Compose using curl. Here we download version 2.19.1 of Docker Compose from the official GitHub repository. Check the release page for the latest version and replace the version part of this URL accordingly. The downloaded file will be saved in the /usr/local/bin directory.

sudo curl -L "https://github.com/docker/compose/releases/download/v2.19.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Next, grant execute permission to the Docker Compose binary file you downloaded. This makes the Docker Compose commands executable.

sudo chmod +x /usr/local/bin/docker-compose

Then, create a symbolic link. A symbolic link creates a reference to a file, in this case /usr/bin/docker-compose, which refers to /usr/local/bin/docker-compose. This allows the docker-compose command to be run from any directory.

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Finally, view the version of Docker Compose to verify that the installation was successful.

docker-compose --version
or
docker compose version

This concludes the instructions for installing Docker Compose on WSL. With this procedure, you can easily manage multiple Docker containers using Docker Compose in a WSL environment.

It is recommended that you regularly check the latest version of Docker Compose and follow the same procedure to update it if a newer version is released. This is important to keep your system up-to-date with new features, security patches, etc.

Now that we are ready to install stable diffusion web ui using docker, we can proceed by referring to the github page.

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

First, clone the repository of the project containing the Stable Diffusion Web UI. The following command is an example, and the specific repository URL will vary depending on the project. Replace “repository_url” below with the actual URL.

git clone repository_url
In this case, it is as follows
git clone https://github.com/AbdBarho/stable-diffusion-webui-docker.git

Next, use Docker Compose to build and run the application. Docker Compose is a tool that allows you to manage the building, starting, and stopping of multiple Docker containers all at once. Docker Compose operates based on a YAML configuration file (usually named docker-compose.yml).

The following command runs Docker Compose with the profile “download”. A profile is a collection of specific services. In this example, the services in the “download” profile will be built and started. The name “download” depends on the specific configuration, so please refer to docker-compose.yml for the specific profile name.

Also, go to the directory created by the git command and execute the command.

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

If you are not sure which profile to choose, it may be safer to select the “auto” profile. The following command will run Docker Compose with the profile “auto”.

docker compose --profile auto up --build

The above procedure will install and launch Stable Diffusion Web UI using Docker. Note that the specific profile name and settings will vary depending on the project and the contents of docker-compose.yml, so please read them accordingly.

Next, enter the command in wsl to check the IP address. In my case, the IP address was 172.22.135.150. I also checked the firewall and found that it was disabled, so I used the following URL to access it.

http://172.22.135.150:7860/

What to do if the following error occurs.

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get “http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.config-hash%22%3Atrue%2C%22com.docker.compose.project%3Dwebui-docker%22%3Atrue%7D%7D”: dial unix /var/run/docker.sock: connect: permission denied

From the error message, it seems that the connection to the docker daemon is not allowed. Docker can be operated only by the root user by default.

First, add the current user (replace “USER_NAME” with your user name) to the docker group.

sudo gpasswd -a USER_NAME docker

Next, verify that the user has been added. If you run this command, you will see the group to which the user belongs, and if “docker” is included in the group, then you have succeeded.

id USER_NAME

However, this setting is effective from a new session, so you must log out and log in again.

exit

After re-logging in, try running the Docker or Docker Compose command again. The previous error should be resolved. For security reasons, we recommend that you add only necessary users to the docker group.

If an error occurs with docker compose.

#0 6.095 07/04 11:11:57 [ERROR] CUID#7 – Download aborted. URI=https://download.pytorch.org/whl/cu118/torch-2.0.1%2Bcu118-cp310-cp310-linux_x86_64.whl
#0 6.095 Exception: [AbstractCommand.cc:351] errorCode=19 URI=https://download.pytorch.org/whl/cu118/torch-2.0.1%2Bcu118-cp310-cp310-linux_x86_64.whl
#0 6.095 -> [AbstractCommand.cc:789] errorCode=19 CUID#7 – Name resolution for download.pytorch.org failed:Timeout while contacting DNS servers
#0 6.095
#0 6.095 07/04 11:11:57 [NOTICE] Download GID#e9d479fda44b0442 not complete: /cache/torch-2.0.1-cp310-cp310-linux_x86_64.whl
#0 6.095
#0 6.095 Download Results:
#0 6.095 gid |stat|avg speed |path/URI
#0 6.095 ======+====+===========+=======================================================
#0 6.095 e9d479|ERR | 0B/s|/cache/torch-2.0.1-cp310-cp310-linux_x86_64.whl
#0 6.095
#0 6.095 Status Legend:
#0 6.095 (ERR):error occurred.
#0 6.098
#0 6.098 aria2 will resume download if the transfer is restarted.
#0 6.098 If there are any errors, then see the log file. See ‘-l’ option in help/man page for details.
——
failed to solve: process “/bin/sh -c aria2c -x 5 –dir /cache –out torch-2.0.1-cp310-cp310-linux_x86_64.whl -c https://download.pytorch.org/whl/cu118/torch-2.0.1%2Bcu118-cp310-cp310-linux_x86_64.whl && pip install /cache/torch-2.0.1-cp310-cp310-linux_x86_64.whl torchvision –index-url https://download.pytorch.org/whl/cu118” did not complete successfully: exit code: 19

This error message indicates that a problem occurred while downloading the PyTorch whl file. Specifically, DNS name resolution has failed. Here are some possible workarounds

  1. Temporary network connection problem: This error may be due to a temporary network problem. If so, check your network connection and try the command again.
  2. DNS server problem: It is also possible that your DNS server is down or overloaded. You may try using a different DNS server; another option is to use Google’s public DNS (8.8.8.8 or 8.8.4.4).
  3. Proxy settings: If your network uses proxies, you will need to check your proxy settings; review your Docker proxy settings and adjust them if necessary.
  4. Problems with the official PyTorch download link: It is also possible that there is a problem with the official PyTorch download link. Try accessing the same URL in your browser and verify that the link is valid.

I got the above error and the download worked by editing the file.

sudo vi /etc/resolv.conf

Write the following

nameserver 8.8.8.8
Please share if you like it!
TOC