Skip to content

Instantly share code, notes, and snippets.

@ann4belle
Last active May 15, 2023 13:51
Show Gist options
  • Save ann4belle/e78fa4602320d9a7244efe782cf8af4a to your computer and use it in GitHub Desktop.
Save ann4belle/e78fa4602320d9a7244efe782cf8af4a to your computer and use it in GitHub Desktop.
Automated install of AUTOMATIC1111/stable-diffusion-webui

This is an extremely simple PowerShell script that will:

To accomplish this, it takes the following steps (labelled in the file):

  1. Install scoop (https://scoop.sh)
  2. Use scoop to install pyenv-win (https://github.com/pyenv-win/pyenv-win) and git (https://git-scm.com/)
  3. Use pyenv to install Python 3.10.6
  4. Use git to clone the stable-diffusion-webui project to the user's Desktop
  5. Write the startup .bat to the user's Desktop

Important Notes

This sets the webui to run using the --medvram and --xformers flags - this can be changed in the webui-user.bat file.

Updates to requirements (such as migrating from one version of torch to another) are NOT handled by either this script or the resulting startup .bat file.

The startup .bat this creates on the Desktop will automatically pull the latest version of stable-diffusion-webui upon running - if that is undesirable, simply remove the call to git pull within it.

I chose scoop and pyenv specifically because they don't require any special permissions to install themselves, and leave the rest of the computer untouched - running this script shouldn't affect existing installations of anything outside of the Scoop ecosystem.

Set-ExecutionPolicy RemoteSigned -Scope Process -Force
irm get.scoop.sh | iex # Step 1
scoop install git pyenv # Step 2
pyenv update
pyenv install 3.10.6 # Step 3
cd $env:userprofile\Desktop
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui "Stable Diffusion" # Step 4
cd "Stable Diffusion"
(Get-Content webui-user.bat).replace('set PYTHON=', 'set PYTHON=%userprofile%\scoop\apps\pyenv\3.1.1\pyenv-win\versions\3.10.6\python.exe').replace('set COMMANDLINE_ARGS=', 'set COMMANDLINE_ARGS=--medvram --xformers --autolaunch') | Set-Content webui-user.bat
cd ..
Write-Output "@echo off`r`ncd ""Stable Diffusion""`r`ngit pull`r`ncall webui-user.bat" | Set-Content StableDiffusion.bat -Encoding ascii # Step 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment