This guide offers a comprehensive walkthrough for setting up and using Stable Diffusion and Automatic1111 on Windows using WSL (Windows Subsystem for Linux) with GPU acceleration. With the provided step-by-step instructions and example screenshots, this guide will help you generate images and harness the full potential of your hardware.
Stable Diffusion is one of the most potent tools for text-to-image generation, and Automatic1111 helps us integrate it with a user-friendly interface and extensive customization options. Let’s dive into the setup process.
Stable Diffusion is a cutting-edge AI model that generates high-quality images from Text prompts. Automatic1111 builds on this by providing:
Whether you’re an artist, researcher, or AI enthusiast, this combination offers flexibility and power for your creative and technical needs.
To enable WSL, open PowerShell and execute the following command:
wsl --install
This command installs WSL and a default Linux distribution (usually Ubuntu).

Once you run the installation command, you must confirm if WSL was successfully installed and works fine. Then, in the command prompt, enter.
wsl --list --verbose

To verify GPU support in WSL, open your WSL terminal and run the command
nvidia-smi
It gives you all the details on your NVIDIA GPU — driver version, GPU name, and how much memory it is using now. Make sure that the GPU is recognized to ensure it’s compatible for running Stable Diffusion and other GPU intensive tasks.

To prepare your system, update the Linux environment and install the required packages.
Run:
sudo apt update && sudo apt upgrade -y
To set up your environment for Stable Diffusion in WSL, install the required libraries and tools by running the following command:
sudo apt install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev git
This checks if important components like compilers, libraries for encryption, compression, and development tools are available. These dependencies are crucial for building Python environments, installing packages, and managing the software required for image generation using Stable Diffusion.

Pyenv is a handy tool for managing Python versions required for stable diffusion. Here’s how to install and configure it:
curl https://pyenv.run | bash
This script is used to download the components of pyenv and configure your shell. Yet, after installation, you must add Pyenv initialization commands to your shell configuration file (e.g., .bashrc or .zshrc).

To configure your environment for Pyenv, you need to add its initialization commands to your shell configuration file. This process makes sure that Pyenv works every time you open a terminal. Just run
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

Reload the configuration:
source ~/.bashrc

With Pyenv configured, the next step is to install the specific Python version required for Stable Diffusion. Using Pyenv, you can easily manage and switch between Python versions. To install Python 3.10.15, execute the command
pyenv install 3.10.15

Once the installation is complete, run it globally using the default Python version.
pyenv global 3.10.15
This step confirms that all dependencies and tools for Stable Diffusion operate seamlessly with the correct Python version.

mkdir stablediff && cd stablediff

To begin installing Stable Diffusion, download the installation script provided by AUTOMATIC1111. Use the command
wget -q https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh
This script contains everything needed to set up the Stable Diffusion web interface, streamlining the process for efficient installation.

After downloading, make the script executable by running.
chmod +x webui.sh

Execute the Bash Script for Starting Installation:
./webui.sh
The script automatically downloads the required components and sets up the environment. Once complete, the web UI will be ready to use, allowing you to generate stunning AI-driven images effortlessly.

The server will start at a local address like http://127.0.0.1:7860. Access it via a web browser.



Select Automatic1111 from the dropdown menu. Enter the Stable Diffusion URL (http://127.0.0.1:7860) and save the settings.

Go to the Automatic1111 interface and find its Text input field to start imaging. Here, type a descriptive prompt that outlines your desired image, such as:
“Generate an image with servers, Ethernet cables, and a man working on servers.”
This prompt enables the AI also to represent your request in the visual form. Be specific enough to achieve goals.

When you trigger the beginning of the image generation, the progress bar in the interface will show you the progress of that in real-time. It shows the percentage complete and an estimated time to finish. With this feature, you can keep a tab on the generation status and know if there’s smooth workflow, while you are waiting for the image.

After the image generation is complete, the final result will be displayed in the output section of the interface. You can view the generated image directly, download it, or adjust your prompt and settings to refine the output. This section also stores previous results for easy access.

To do that in OpenWebUI, go to the Model Selection area. Select a model with an image generation feature like Stable Diffusion, or use one you consider. Choosing the proper model ensures compliance with the input prompt and sound output for the specific image generation work.

In the OpenWebUI interface, input your desired prompt in the Text field, describing your desired image (e.g., “A futuristic city skyline at sunset”). After entering the prompt, please wait for the system to process it. Once the response initializes, click the Generate Image button to create your image.

After the generation process is complete, the output image will appear in the results section of the OpenWebUI interface. You can view the image directly within the interface, download it for personal use, or save it to your specified output directory. If unsatisfied, tweak your prompt or settings and regenerate.

If you are using Nvidia GPUs alongside WSL, then to monitor your GPU performance while performing tasks in WSL, use the Nvidia-smi command. This tool offers GPU mainly the details of memory consumption, GPU utilization, processes that are running, and temperature of the GPU used. Run the command in your WSL terminal:
nvidia-smi

This command helps you identify bottlenecks, optimize resource usage, and ensure that your GPU correctly handles tasks such as image generation with Stable Diffusion without any issues.
Following this guide, it is easy to set up Stable Diffusion and Automatic1111 in a WSL environment with a GPU. The installation process is well described and elaborated with steps allowing for unproblematic installation, setup, and all subsequent usages, making you accomplish the perfect images. Use prompts, discover new customization possibilities, and extend the possibilities of Stable Diffusion usage.

Vinayak Baranwal wrote this article. Use the provided link to connect with Vinayak on LinkedIn for more insightful content or collaboration opportunities.