👉 Want to run Stable Diffusion on macOS with Apple Silicon (M-series), but do not want to install all the code on your local machine?
Stable Diffusion Prompt: A beautifully colored cat sitting in the clouds with a rainbow in the background, in the style of Andy Warhol |
This repo contains a Dockerfile and scripts that will allow you to run the Stable Diffusion Web UI (SDWUI) from AUTOMATIC1111 on your machine using Docker and Visual Studio Code. This means you do not have to install things like Python and all the other required dependencies directly on your computer.
If you know what you are doing with Docker and Visual Studio code, then continue on with the instructions below, but please read the FAQ and Docker details in this Gist.
If you do not know what you are doing, ignore this repo and follow the instructions in my Gist instead.
Before you run this code, make sure you have the following:
- An Apple Mac running Apple Silicon with macOS Ventura (minimum)
- A Docker account and the Apple Chip Docker desktop installed locally
- Visual Studio Code for Apple Silicon
- At minimum, a free GitHub account
While this Gist will give you more information, I suggest you run the Docker Desktop, go to ⚙ Settings->Resources
and pump up the resources. You can lower them later.
- Install the
Docker
extension from Microsoft - Install the
Dev Container
extension from Microsoft
For purposes of this README, you will clone the repo, but feel free to download and extract the file, fork it, or get the code any way you like. Just make sure you enable Git and do an initial commit before the first-time setup.
- Run VSC, clone this repo locally and open the folder
https://github.com/BillRaymond/run-automatic1111-stable-diffusion-web-ui-macos-docker
- Type
COMMMAND+SHIFT+P
and select theDev Containers: Open folder in container...
option - Select
Dockerfile
and if prompted to install additional items, do not select them and selectOk
Run these steps immediately after building the Docker container from the Dockerfile.
You do not need to run the code again. Later, you might want to pull an even newer version of AUTOMATIC1111/stable-diffusion-web-ui code from GitHub, but that is something you will have to do manually.
- In VSC, open a terminal window
- To clone the AUTOMATIC1111/stable-diffusion-web-ui code, type the following in the terminal window:
sh runonce-step1-clone-sdwui.sh
- Stable diffusion cannot run without a model. You can download a model yourself and put it in the correct
stable-diffusion-web-ui/models
folder. Or, you can run the following command in the terminal and it will download the file for you.
sh runonce-step2-downloadsdmodel.sh
- You will need to edit some code in the
stable-diffusion-web-ui
folder. Run the following command in a terminal window for instructions:
sh runonce-step3-instructions.sh
⚠️ Make sure youkill
the terminal window (a 🗑️ trash can icon) orCOMMAND+SHIFT+P
andTerminal: Kill all terminals
To run SDWUI, you need a non-root user. This script will create that user. If you attempt to run this again, you could encounter an error. However, if you re-build the Docker container, you will have to run this again.
- Open a new terminal within VSC and run the following script in terminal to crate a non-root user (by default it will be named
sdwui
):
sh runonce-step4-addnonrootuser.sh
⚠️ Make sure youkill
the terminal window (a 🗑️ trash can icon) orCOMMAND+SHIFT+P
andTerminal: Kill all terminals
Now that you followed all the first-time setup options, you can run SDWUI!
- Open a new terminal within VSC and run the following command:
sh runsdwui.sh
- At some time in the process, a URL will appear in the terminal window, like this:
http://127.0.0.1:7860
. Locate the url andCOMMAND+CLICK
to open SDWUI in the browser.
⚠️ Beware!: The URL may show, but the model(s) may still be loading, so watch the terminal window before attempting to use SDWUI.
- Once the models are built, you can use SDWUI in the browser! As always, remember it will be slow and may crash. This is still a Docker container running Linux on top of macOS.
Visit this Gist and check out the FAQ and Docker sections.