automatic1111 stable diffusion setup guide
this interactive guide provides a comprehensive, step-by-step process to install and run the automatic1111 stable diffusion web ui on your Windows laptop, leveraging docker desktop and WSL2 for optimal performance and dependency management. this guide incorporates common issues and their solutions directly within the relevant steps, allowing for a smoother installation experience.
your setup:
- laptop: your Windows machine (e.g., a Legion 7i)
- gpu: NVIDIA GeForce RTX 3060
- operating system: Windows 11
- goal: run automatic1111 stable diffusion web ui
how to use this guide:
- follow the steps in order, executing commands in your Ubuntu Terminal (WSL2) unless specified.
- click on the `+` icon next to "troubleshooting an error" to reveal common problems and their fixes for that step.
- ensure docker desktop is running on Windows before starting docker-related commands.
phase 1: core Windows & WSL2 environment setup
this initial phase ensures your base windows and linux environments are correctly configured, laying the groundwork for docker and gpu integration. follow these steps sequentially in your windows environment or PowerShell.
step 1: system preparation & NVIDIA drivers
ensure your Windows 11 is fully updated.
download and install the latest NVIDIA game ready or studio drivers directly from NVIDIA's official website for your RTX GPU. this is crucial for your Windows host system.
step 2: install Ubuntu (your WSL2 Linux distribution)
open PowerShell as Administrator.
troubleshooting an error: `wsl --install --online`
attempted command (and error): `wsl --install --online`
error message: `Wsl/E INVALIDARG`
explanation & fix: the `--online` flag is not a recognized argument for `wsl --install`. the command is simpler.
correct command:
wsl --install -d Ubuntu
*(this will download and install the latest LTS Ubuntu (likely 22.04). it will prompt you to create a new Linux username and password once Ubuntu starts for the first time. for the username, avoid common names like 'mail' and choose something like 'mailroger' or 'devuser'.)*
close the Ubuntu window after user creation. in the same PowerShell (Admin) window, run:
wsl --set-default-version 2
verify your installation:
wsl --list --verbose
*(ensure Ubuntu shows `Version 2` and its state is `Stopped` or `Running`.)*
step 3: install docker desktop (official website)
it's important to use the official installer to ensure consistent setup.
- go to: docker.com/products/docker-desktop/
- download the Windows installer (.exe file). for your Intel i7 processor, ensure you download the Windows AMD64 version.
- run the downloaded `.exe` file. during installation, ensure the "use WSL 2 instead of Hyper-V (recommended)" option is checked.
- complete the installation and start docker desktop.
- in the docker desktop dashboard, go to settings (gear icon) -> resources -> WSL integration. make sure the toggle for your Ubuntu distribution is ON.
step 4: initial system reboot
restart your entire Windows laptop. this is crucial to ensure docker desktop and WSL2 are fully integrated and all changes take effect.
phase 2: enable NVIDIA GPU for docker in WSL2
this phase configures your WSL2 Ubuntu environment and Docker to recognize and utilize your NVIDIA GPU, which is essential for Stable Diffusion's performance. execute these commands in your Ubuntu terminal.
step 1: open Ubuntu terminal
launch the `Windows Terminal` app. open a new tab or window by selecting your Ubuntu distribution from the dropdown. you will be at your Ubuntu command prompt (e.g., mailroger@<hostname>:~$
).
step 2: install NVIDIA container toolkit repository & key
this command block adds the NVIDIA repository and its GPG key to your Ubuntu system's package manager (`apt`), allowing it to securely download NVIDIA's Docker tools.
troubleshooting an error: `<!doctype html>` HTML output
prior error (HTML output): when using a previous version of the command, the `curl` command might have returned HTML (starting `<!doctype html>`) instead of the repository list.
explanation & fix: this happened because the URL path for the NVIDIA repository list had changed. the original command structure was looking for a file that no longer existed at that precise path, leading the server to return an an HTML "Not Found" page.
troubleshooting an error: `NO_PUBKEY` and `404 not found` in `apt update`
prior error:
W: GPG error: https://nvidia.github.io/libnvidia-container/stable/deb/amd64 InRelease: the following signatures couldn't be verified because the public key is not available: NO_PUBKEY DDCAE044F796ECB0
e: the repository 'https://nvidia.github.io/libnvidia-container/stable/deb/amd64 InRelease' is not signed.
err:6 https://nvidia.github.io/libnvidia-container/stable/deb Release 404 not found [IP: 185.199.108.153 443]
explanation & fix: these errors occurred because apt couldn't verify the repository's signature (meaning the GPG key wasn't correctly linked) or because the repository URL in the `sources.list.d` file was pointing to a non-existent location within NVIDIA's server structure (`/stable/deb/` instead of `/stable/deb/amd64/`). the fix involves precisely defining the repository line with the correct architecture in the path and ensuring the `signed-by` directive is perfect.
corrected command (copy and paste this ENTIRE block as a single command):
sudo rm -f /etc/apt/sources.list.d/nvidia-container-toolkit.list && \
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/stable/deb/amd64/ /" | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
*(you will be prompted for your Ubuntu user password. enter it.)*
step 3: update package list & install NVIDIA container toolkit
in the same Ubuntu terminal:
sudo apt update
sudo apt install -y nvidia-container-toolkit
*(`apt update` refreshes the package list, `apt install` downloads and installs the toolkit. this should now complete without errors.)*
step 4: restart docker service (crucial for toolkit recognition)
troubleshooting an error: `failed to restart docker service unit.docker not found`
prior error: `failed to restart docker service unit.docker not found`
explanation & fix: the docker daemon runs on your windows host, not directly as a `systemd` service within your WSL2 Ubuntu distro. the `systemctl` or `service` commands in Ubuntu can't directly control it. to reload docker's configuration, docker desktop on windows needs to be restarted.
correct action:
- open PowerShell as Administrator (on Windows).
- run:
(this stops all WSL2 distros and docker's WSL2 backend.)wsl --shutdown
- close docker desktop completely (right-click the docker whale icon in your windows system tray and select "quit docker desktop").
- restart docker desktop from your windows start menu.
phase 3: automatic1111 web ui with docker compose & models
this is the final stage to get the web ui running, incorporating a crucial dockerfile fix. execute these commands in your Ubuntu terminal.
step 1: clone automatic1111 docker repository
open your Ubuntu terminal (if it's not already open from the previous step). navigate to your Linux home directory:
cd ~
clone the `AbdBarho` repository and enter its directory:
git clone https://github.com/AbdBarho/stable-diffusion-webui-docker.git
cd stable-diffusion-webui-docker
step 2: prepare model directories & (optionally) copy any models you already have
create the necessary subdirectories for your models within the stable-diffusion-webui-docker
folder:
mkdir -p data/models/Stable-diffusion
mkdir -p data/models/Lora
mkdir -p data/models/VAE
# add others if you have them: ControlNet, etc. (e.g., mkdir -p data/models/ControlNet)
copy your .safetensors
or .ckpt
model files from your easy diffusion installation (e.g., C:\Users\YourWindowsUser\EasyDiffusion\models
) into these newly created subfolders in your WSL2 environment.
- you can access your WSL2 folders from windows file explorer by typing
\\wsl$\
in the address bar. - then navigate to:
\\wsl$\Ubuntu\home\mailroger\stable-diffusion-webui-docker\data\models\
- ensure models go into
Stable-diffusion/
, LoRAs intoLora/
, VAEs intoVAE/
, etc.
*(this step saves you from re-downloading large files.)*
step 3: edit dockerfile to fix `typing_extensions` error
troubleshooting an error: `importError: cannot import name 'TypeIs' from 'typing_extensions'`
prior error: `importError: cannot import name 'TypeIs' from 'typing_extensions'`
explanation & fix: the docker container because the `typing_extensions` Python package (a dependency of Automatic1111) was an older version that didn't include the `TypeIs` feature. we need to explicitly upgrade it during the docker image build process.
open the correct Dockerfile for the automatic1111 service:
nano services/AUTOMATIC1111/Dockerfile
insert this exact line: RUN pip install --upgrade typing_extensions
- place this line on a new line immediately after the
pip install -r requirements.txt
line (or the last majorpip install
command) within the secondFROM pytorch/pytorch...
block. - ensure it's placed before any
CMD
orENTRYPOINT
lines at the very end.
save and exit `nano`:** press Ctrl + O
, then Enter
, then Ctrl + X
.
step 4: start automatic1111 web ui
troubleshooting an error: `no service selected`
prior error: `no service selected`
explanation & fix: this happened because the `docker compose` command wasn't told *which* specific service or profile to run from the `docker-compose.yml` file. the `AbdBarho` repository uses profiles (like `auto` for NVIDIA GPUs).
ensure you are in the ~/stable-diffusion-webui-docker
directory.
docker compose --profile auto up --build
*(the `--build` flag ensures docker rebuilds the image with your dockerfile change. it will use cached layers for unchanged steps, making it faster than the very first build.)*
monitor the output. you will see docker layers downloading and setting up. look for the message indicating the web ui is running.
*expected success message: running on local URL: http://0.0.0.0:7860
or http://127.0.0.1:7860
*(you will also see warnings like `FutureWarning` or `WARN` related to casing; these are harmless and can be ignored.)*
step 5: access the web ui
once you see the URL in your Ubuntu terminal, open your web browser (on Windows) and go to:
http://localhost:7860
managing the application (start/stop)
once your automatic1111 web ui is successfully set up and running, here's how to start and stop it for everyday use. all commands should be run from your Ubuntu terminal in your ~/stable-diffusion-webui-docker
directory.
to start the web ui (on demand):
to start the web ui in the background (detached mode), which is generally more convenient:
docker compose --profile auto up -d
*(this will free up your terminal. to view logs of a detached container, use docker compose logs -f auto
. press Ctrl+C
to stop following logs.)*
alternatively, to run in the foreground (your terminal will show logs):
docker compose --profile auto up
to stop the web ui (on demand):
to cleanly shut down the running container(s):
docker compose down
*(this will gracefully shut down the automatic1111 web ui, making it inaccessible.)*
using docker desktop GUI:
you can also manage the container directly from the docker desktop application:
- open docker desktop.
- go to the "containers / apps" tab.
- locate your container, typically named
webui-docker-auto-1
. - use the play (▶), stop (⬛), or restart (⟳) buttons to control the container.