Skip to content

One-click install for StabilityAI's Stable-Diffusion with AUTOMATIC1111's webui

License

Notifications You must be signed in to change notification settings

goodlux/Stable-Diffusion-WSL2-Docker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stable-Diffusion-WSL2-Docker

About

This repository is meant to allow for easy installation of Stable Diffusion on Windows. One click to install. Second click to run. (It is recommended to click install script before heading to bed - depends on your internet connection.)

This setup is completely dependant on current versions of AUTOMATIC1111's webui repository and StabilityAI's Stable-Diffusion models.

In it's current configuration only Nvidia GPUs are supported. This script will also install Xformers library in order to speed up output generation.

Prerequisites

Before following through with these instructions. Please verify below.

  1. You have virtualization support - easiest way is to check if you can see "Virtualization" section in Windows Task Manager -> Performance -> CPU (it's located under "More details" if you don't see the Performance tab).
  2. You have virtualization enabled - you have to enable it in your BIOS if you don't.
  3. You have Windows 11 Pro - you can also use Windows 11 Home (and according to some Stack Overflow comments also Windows 10), but you will have to perform manual installation and adjust it to your needs - e.g. Home edition needs a workaround in order to install Hyper-V.
  4. 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 11.

How to use

After installation simply execute run.bat file to start the Stable-Diffusion app. You can open it under http://localhost:7860.

If you want to close the app - simply launch stop.bat, it will terminate the application and close the terminals.

Note! 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.

Installation

Automatic

Run install.bat in order to install the Stable Diffusion - this process will restart your computer at the beginning, and will take a long time to download.

Manual

  1. Install Windows 11
  2. Install WSL from MS Store (https://www.microsoft.com/store/productId/9P9TQF7MRM4R)
  3. Search for "Turn Windows features on or off" and enable "Hyper-V"
  4. Set WSL to use v2: wsl --set-default-version 2
  5. Install Linux distro of your choice (Ubuntu given as example): wsl --install Ubuntu
    1. Set up your username and password
  6. (In distro command line) sudo sh -c 'echo "[boot]\nsystemd=true" > /etc/wsl.conf'
  7. Check your distro name using "wsl --list"
  8. Shutdown all distros "wsl --shutdown" and restart the one we're using "wsl --distribution Ubuntu"
  9. Make sure you have nvidia drivers installed on Windows
  10. Now open WSL. From now on, everything is executed from there.
  11. Execute following scripts:
    1. sudo apt-key del 7fa2af80
    2. wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
    3. sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
    4. sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/3bf863cc.pub
    5. sudo add-apt-repository 'deb https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/ /'
    6. sudo apt-get update
    7. sudo apt-get -y install cuda
  12. Check if you're able to see your GPU in WSL: nvidia-smi
  13. Install docker: curl https://get.docker.com | sh
    && sudo systemctl --now enable docker
  14. distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
    && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
    && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list |
    sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' |
    sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
  15. sudo apt-get install -y nvidia-docker2
  16. sudo systemctl restart docker
  17. Check if docker container also sees your GPU: sudo docker run --rm --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi
  18. Run ./build.sh from repo directory to build the container (you can remove depth, upscaler, inpainting and gfpgan from Dockerfile to minimize downloads and size)
  19. Run ./run.sh to start container. Open http://localhost:7860 to access the webui - you can do so from Windows of course.

Sources

  1. StabilityAI Stable-Diffusion GitHub
  2. StabilityAI Stable-Diffusion HuggingFace
  3. AUTOMATIC1111 webui
  4. Nvidia Container Runtime
  5. Ubuntu GPU acceleration on WSL2
  6. MS WSL systemd
  7. Nvidia WSL

About

One-click install for StabilityAI's Stable-Diffusion with AUTOMATIC1111's webui

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PowerShell 69.0%
  • Dockerfile 20.0%
  • Shell 7.1%
  • Batchfile 2.5%
  • Python 1.4%