Optimizing Deep Learning Workflows Leveraging Stable Diffusion and Docker on WSL 2

December 8, 2025 · 1499 words · 8 min

Deep learning has revolutionized the field of artificial intelligence (AI) by enabling machines to l

Deep learning has revolutionized the field of artificial intelligence (AI) by enabling machines to learn and generate content that mimics human-like creativity. One advancement in this domain is , a text-to-image model released in 2022.  Stable Diffusion has gained significant attention for its ability to generate highly detailed images conditioned on text descriptions, thereby opening up new possibilities in areas such as creative design, visual storytelling, and content generation. With its open source nature and accessibility, Stable Diffusion has become a go-to tool for many researchers and developers seeking to harness the power of deep learning.  In this article, we will explore how to optimize deep learning workflows by leveraging Stable Diffusion alongside , enabling seamless and efficient experimentation with this cutting-edge technology. In this comprehensive guide, we will walk through the process of setting up the , which includes enabling WSL 2 and installing . You will learn how to download the required code from GitHub and initialize it using .  The guide provides instructions on adding additional models and managing the system, covering essential tasks such as reloading the UI and determining the ideal location for saving image output. Troubleshooting steps and tips for monitoring hardware and GPU usage are also included, ensuring a smooth and efficient experience with (Figure 1). In the realm of image-based generative AI, setting up an effective execution and development environment on a Windows PC can present particular challenges. These challenges arise due to differences in software dependencies, compatibility issues, and the need for specialized tools and frameworks. Docker Desktop emerges as a powerful solution to tackle these challenges by providing a containerization platform that ensures consistency and reproducibility across different systems. By leveraging Docker Desktop, we can create an isolated environment that encapsulates all the necessary components and dependencies required for image-based generative AI workflows. This approach eliminates the complexities associated with manual software installations, conflicting library versions, and system-specific configurations. The is a browser interface that is built upon the Gradio library, offering a convenient way to interact with and explore the capabilities of Stable Diffusion. Gradio is a powerful Python library that simplifies the process of creating interactive interfaces for machine learning models. Setting up the Stable Diffusion WebUI environment can be a tedious and time-consuming process, requiring multiple steps for environment construction. However, a convenient solution is available in the form of This Docker image eliminates the need for manual setup by providing a preconfigured environment. If you’re using Windows and have Docker Desktop installed, you can effortlessly build and run the environment using the command. You don’t have to worry about preparing libraries or dependencies beforehand because everything is encapsulated within the container. You might wonder whether there are any problems because it’s a container. I was anxious before I started using it, but I haven’t had any particular problems so far. The images, models, variational autoencoders (VAEs), and other data that are generated are shared (bind mounted) with my Windows machine, so I can exchange files simply by dragging them in Explorer or in the of the target container on Docker Desktop.  The most trouble I had was when I disabled the extension without backing it up, and in a moment blew away about 50GB of data that I had spent half a day training. (This is a joke!) I’ve compiled a relatively simple procedure to start with Stable Diffusion using Docker Desktop on Windows.  We will use the WebUI called AUTOMATIC1111 to utilize Stable Diffusion this time. The environment for these will be constructed using Docker Compose. The main components are shown in Figure 2. The configuration of Docker Compose is defined in . We are using a Compose extension called to describe the major components common to each service. To start, there are settings for between the host and the container, including , which loads modes, and , which outputs images. Then, we make the container recognize the GPU by loading the NVIDIA driver. Furthermore, the service named runs AUTOMATIC1111, WebUI for Stable Diffusion, within the container. Because there is a port mapping (TCP:7860), between the host and the container in the aforementioned common service settings, it is possible to access from the browser on the host side to the inside of the container. WSL 2 must be activated and Docker Desktop installed. On the first execution, it downloads 12GB of Stable Diffusion 1.5 models, etc. The Web UI cannot be used until this download is complete. Depending on your connection, it may take a long time until the first startup. First, from GitHub. If you download it as a ZIP, click and the file will be downloaded (Figure 3).  Unzip the file in a convenient location. When you expand it, you will find a folder named . Open the command line or similar and run the command inside it. Or, if you have an environment where you can use Git, such as Git for Windows, it’s quicker to download it as follows: In this case, the folder name is . Move it with . If you just want to get started, you can skip this section. By default, the timezone is UTC. To adjust the time displayed in the log and the date of the directory generated under to Japan time, add to the environment variables of the service. Specifically, add the following description to . The rest of the process is as described in . Inside the folder where the code is expanded, run the following command: After the command runs, the log of a container named will be displayed on the screen. For a while, the download will run as follows, so wait until it is complete: If the process ends successfully, it will be displayed as and returned to the original prompt: If a code other than 0 comes out like the following, the download process has failed: In this case, run the command again and check whether it ends successfully. Once it finishes successfully, run the command to start the WebUI.  The following is for AUTOMATIC1111’s UI and GPU specification: When you run the command, loading the model at the first startup may take a few minutes. It may look like it’s frozen like the following display, but that’s okay: If you wait for a while, the log will flow, and the following URL will be displayed: Now the startup preparation of the Web UI is set. If you open from the browser, you can see the Web UI. Once open, select an appropriate model from the top left of the screen, write some text in the text field, and select the button to start generating images (Figure 4). When you click, the button will be reversed. Wait until the process is finished (Figure 5). At this time, the log of image generation appears on the terminal you are operating, and you can also check the similar display by looking at the log of the container on Docker Desktop (Figure 6). When the status reaches 100%, the generation of the image is finished, and you can check it on the screen (Figure 7). The created images are automatically saved in the folder directly under the directory where you ran the command. To stop the launched WebUI, enter on the terminal that is still running the command. When the process ends successfully, you will be able to run the command again. To use the WebUI again after restarting, re-run the command: To see the operating hardware status, use the task manager to look at the GPU status (Figure 8). To check whether the GPU is visible from inside the container and to see whether the information comes out, run the command from or the Docker Desktop terminal. If you download a model that is not included from the beginning, place files with extensions, such as in . In the case of VAE, place files in . If you’re using Docker Desktop, you can view and operate inside on the of the container, so you can also drag it into Docker Desktop.  Figure 9 shows the Docker Desktop screen. It says in the column, and it shares the information in the folder with the container from the Windows host side. Now, after placing the file, a link to is shown in the footer of the WebUI, so select there (Figure 10). When you select , the system will show a loading screen, and the browser connection will be cut off. When you reload the browser, the model and VAE files are automatically loaded. To remove a model, delete the model file from . With Docker Desktop, image generation using the latest generative AI environment can be done easier than ever. Typically, a lot of time and effort is required just to set up the environment, but Docker Desktop solves this complexity. If you’re interested, why not take a challenge in the world of generative AI? Enjoy!