Skip to content

Instantly share code, notes, and snippets.

@narphorium
Last active September 5, 2022 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save narphorium/0a2013dadb491939ae2c345ceeae942a to your computer and use it in GitHub Desktop.
Save narphorium/0a2013dadb491939ae2c345ceeae942a to your computer and use it in GitHub Desktop.

Running Stable Diffusion on an M1 Mac

Based off of instructions from Run Stable Diffusion on your M1 Mac’s GPU

  1. Make sure that you have Command Line Tools for Xcode installed:
sudo xcode-select --install
  1. Install homebrew:
cd usr/local/bin
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

eval "$(homebrew/bin/brew shellenv)"
brew update --force --quiet
chmod -R go-w "$(brew --prefix)/share/zsh"
  1. Add Homebrew binaries to your PATH:
echo 'PATH="/usr/local/bin/:$PATH"' >> ~/.bash_profile
  1. Activate the new PATH variable:
source ~/.bash_profile
  1. Install Python 3.10:
brew install python
  1. Verify that Python 3.10 is the new default interpreter:
python3 -V  
  1. Install a few other dependencies:
brew install Cmake protobuf rust
  1. Clone the Stable Diffusions repo:
mkdir ~/Documents/GitHub
cd ~/Documents/GitHub
git clone -b apple-silicon-mps-support https://github.com/bfirsh/stable-diffusion.git

cd stable-diffusion
mkdir -p models/ldm/stable-diffusion-v1/
  1. Create a virtual environment:
python3 -m venv .venv
  1. Make sure that .venv/pyvenv.cfg shows:
version = 3.10.6
  1. Activate the virtual environment:
source .venv/bin/activate
  1. Install the dependencies:
pip3 install -r requirements.txt
  1. Go to Hugging Face and create an account if you don't already have one.

  2. Go to the Stable Diffiusion Hugging Face repository.

  3. Click "Access repository".

  4. Download sd-v1-4.ckpt (~4 GB) on that page and save it as models/ldm/stable-diffusion-v1/model.ckpt in the directory you created above.

  5. Create an image locally:

python3 scripts/txt2img.py \
  --prompt "a red juicy apple floating in outer space, like a planet" \
  --n_samples 1 --n_iter 1 --plms --skip_grid --ddim_steps=100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment