{"id":19775573,"url":"https://github.com/rgryta/stable-diffusion-wsl2-docker","last_synced_at":"2025-06-16T04:07:13.154Z","repository":{"id":103976589,"uuid":"577378224","full_name":"rgryta/Stable-Diffusion-WSL2-Docker","owner":"rgryta","description":"One-click install for StabilityAI's Stable-Diffusion with AUTOMATIC1111's webui","archived":false,"fork":false,"pushed_at":"2024-02-11T09:48:09.000Z","size":23,"stargazers_count":111,"open_issues_count":4,"forks_count":18,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T04:08:20.716Z","etag":null,"topics":["ai","docker","dockerfile","nvidia","stability-ai","stable-diffusion","ubuntu","wsl","wsl2"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rgryta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-12-12T15:51:24.000Z","updated_at":"2025-04-03T04:14:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"7b13262a-9677-4981-8860-2d32c919621c","html_url":"https://github.com/rgryta/Stable-Diffusion-WSL2-Docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgryta%2FStable-Diffusion-WSL2-Docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgryta%2FStable-Diffusion-WSL2-Docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgryta%2FStable-Diffusion-WSL2-Docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgryta%2FStable-Diffusion-WSL2-Docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rgryta","download_url":"https://codeload.github.com/rgryta/Stable-Diffusion-WSL2-Docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251769211,"owners_count":21640863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","docker","dockerfile","nvidia","stability-ai","stable-diffusion","ubuntu","wsl","wsl2"],"created_at":"2024-11-12T05:16:49.302Z","updated_at":"2025-04-30T19:30:38.201Z","avatar_url":"https://github.com/rgryta.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stable Diffusion on Docker (WSL2)\r\n\r\n## About\r\n\r\nThis repository is meant to allow for easy installation of Stable Diffusion on Windows. One click to install. Second click to start.\r\n\r\nThis setup is completely dependant on current versions of AUTOMATIC1111's webui repository and StabilityAI's Stable-Diffusion models.\r\n\r\nIn it's current configuration only Nvidia GPUs are supported. This script will also install all dependencies (including xformers) in order to speed up launching the webui.\r\n\r\n## Prerequisites\r\n\r\nBefore following through with these instructions. Please verify below.\r\n\r\n1. You have virtualization support - easiest way is to check if you can see \"Virtualization\" section in Windows Task Manager -\u003e Performance -\u003e CPU (it's located under \"More details\" if you don't see the Performance tab).\r\n1. You have virtualization enabled - you have to enable it in your BIOS if you don't.\r\n1. You have Windows 11 Pro - you can also use Windows 11 Home (also Windows 10 above certain version), but I cannot guarantee that provided scripts will work their magic.\r\n1. You have Nvidia GPU - this is mandatory for current configuration. Support for AMD is presumably possible, but won't be added until such request shows up. Make sure you also have the newest drivers! Whole repository is based on CUDA 12 - you will be limited to GTX 900-series or higher.\r\n1. You need admin access. These scripts use a PowerShell library that I've prepared, called [WSLTools](https://github.com/rgryta/PowerShell-WSLTools) (handles automatic and interactive installation of WSL distributions from source), you need to have admin privileges to install this module.\r\n\r\n## How to use\r\n\r\nAfter installation simply execute start.bat file to start the Stable-Diffusion app. You can open it under [http://localhost:7860](http://localhost:7860).\r\n\r\nIf you want to close the app - simply launch stop.bat, it will terminate the application and close the terminals.\r\n\r\nNote! Keep in mind that stop.bat will terminate and remove all containers based on Stable-Diffusion webui image. If you have downloaded additional models while the application was running - e.g. GAN models - they will have to be redownloaded again.\r\n\r\n## Installation\r\n\r\n### Automatic\r\n\r\nRun install.bat in order to install the Stable Diffusion. This will take a while - as long as you don't see red errors - everything's fine. I takes about 20min to install on my machine.\r\n\r\n### Manual\r\n\r\n1. Install Windows 11\r\n1. Install WSL from MS Store (https://www.microsoft.com/store/productId/9P9TQF7MRM4R)\r\n1. Search for \"Turn Windows features on or off\" and enable \"Hyper-V\"\r\n1. Set WSL to use v2: `wsl --set-default-version 2`\r\n1. Install Linux distro of your choice (Ubuntu given as example): `wsl --install Ubuntu`\r\n\t1. Set up your username and password\r\n1. (In distro command line) `sudo sh -c 'echo \"[boot]\\nsystemd=true\" \u003e /etc/wsl.conf'`\r\n1. Check your distro name using `wsl --list`\r\n1. Shutdown all distros `wsl --shutdown` and restart the one we're using `wsl --distribution Ubuntu`\r\n1. Make sure you have nvidia drivers installed on Windows\r\n1. Now open WSL. From now on, everything is executed from there.\r\n1. Execute following scripts (installs cuda drivers):\r\n\t```bash\r\n\tsudo apt-key del 7fa2af80\r\n\twget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin\r\n\tsudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600\r\n\tsudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/3bf863cc.pub\r\n\tsudo add-apt-repository 'deb https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/ /'\r\n\tsudo apt-get update\r\n\tsudo apt-get -y install cuda\r\n\t```\r\n1. Check if you're able to see your GPU in WSL: nvidia-smi\r\n1. Install docker:\r\n\t```bash\r\n\tcurl https://get.docker.com | sh \\\r\n\t\u0026\u0026 sudo systemctl --now enable docker\r\n\t```\r\n1. Prepare gpg keys to install nvidia-docker:\r\n\t```bash\r\n\tdistribution=$(. /etc/os-release;echo $ID$VERSION_ID) \\\r\n\t\u0026\u0026 curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \\\r\n\t\u0026\u0026 curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \\\r\n\tsed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \\\r\n\tsudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list\r\n\t```\r\n1. Now we can install it: `sudo apt-get install -y nvidia-docker2`\r\n1. Restart docker service: `sudo systemctl restart docker`\r\n1. Check if docker container also sees your GPU: `sudo docker run --rm --gpus all nvidia/cuda:12.0.1-base-ubuntu22.04 nvidia-smi`\r\n1. Run `./build.sh` from repo directory to build the container. You can uncomment depth, upscaler, inpainting and gfpgan from Dockerfile (first generated image) but it will take much more space - default installation is ~25GB total.\r\n1. Run `./run.sh` to start container. Open http://localhost:7860 to access the webui - you can do so from Windows of course.\r\n\r\n## Sources\r\n\r\n1. [StabilityAI Stable-Diffusion GitHub](https://github.com/Stability-AI/stablediffusion)\r\n1. [StabilityAI Stable-Diffusion HuggingFace](https://huggingface.co/stabilityai/stable-diffusion-2-1)\r\n1. [AUTOMATIC1111 webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)\r\n1. [Nvidia Container Runtime](https://nvidia.github.io/nvidia-container-runtime/)\r\n1. [Ubuntu GPU acceleration on WSL2](https://ubuntu.com/tutorials/enabling-gpu-acceleration-on-ubuntu-on-wsl2-with-the-nvidia-cuda-platform#3-install-nvidia-cuda-on-ubuntu)\r\n1. [MS WSL systemd](https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/)\r\n1. [Nvidia WSL](https://docs.nvidia.com/cuda/wsl-user-guide/index.html)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgryta%2Fstable-diffusion-wsl2-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frgryta%2Fstable-diffusion-wsl2-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgryta%2Fstable-diffusion-wsl2-docker/lists"}