Based off of instructions from Run Stable Diffusion on your M1 Mac’s GPU
- Make sure that you have Command Line Tools for Xcode installed:
sudo xcode-select --install
- 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"
- Add Homebrew binaries to your PATH:
echo 'PATH="/usr/local/bin/:$PATH"' >> ~/.bash_profile
- Activate the new PATH variable:
source ~/.bash_profile
- Install Python 3.10:
brew install python
- Verify that Python 3.10 is the new default interpreter:
python3 -V
- Install a few other dependencies:
brew install Cmake protobuf rust
- 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/
- Create a virtual environment:
python3 -m venv .venv
- Make sure that
.venv/pyvenv.cfg
shows:
version = 3.10.6
- Activate the virtual environment:
source .venv/bin/activate
- Install the dependencies:
pip3 install -r requirements.txt
-
Go to Hugging Face and create an account if you don't already have one.
-
Go to the Stable Diffiusion Hugging Face repository.
-
Click "Access repository".
-
Download
sd-v1-4.ckpt
(~4 GB) on that page and save it asmodels/ldm/stable-diffusion-v1/model.ckpt
in the directory you created above. -
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