How to install and run Stable Diffusion on Apple Silicon M1/M2 Macs

Updated Categorized as Tutorial Tagged 13 Comments on How to install and run Stable Diffusion on Apple Silicon M1/M2 Macs
Install Stable diffusion on Mac

Stable Diffusion is a text-to-image AI that can be run on personal computers like Mac M1 or M2. In this article, you will find a step-by-step guide for installing and running Stable Diffusion on Mac.

You will need a Mac with Apple Silicon (M1 or M2) for reasonable speed. Ideally, your machine will have 16 GB of memory or more. You will need to wait longer for an image compared to using a similarly priced Windows PC with a discrete graphics card.

Here are the install options I will go through in this article.

  1. Draw Things – Easiest to install with a good set of features.
  2. Diffusers – Easiest to install but with not many features.
  3. DiffusionBee – Easy to install but with a smaller set of functions.
  4. AUTOMATIC1111 – Best features but a bit harder to install.

Alternatively, you can run Stable Diffusion in Google Colab which uses AUTOMATIC1111 (This is what I use and I am a Mac user). Check the Quick Start Guide for details.

Read this install guide if you want to install Stable Diffusion on a Windows PC.

Draw Things App

Install Instructions

Draw Things

Draw Things is an Apple App that can be installed on iPhones, iPad, and Macs. Installing it is no different from installing any other App.

App Product Page

It supports a pretty extensive list of models out of the box and a reasonable set of customizations you can make. It also supports inpainting.

Pros and Cons of Draw Things App

Pros

  • Easy to install
  • A good set of features

Cons

  • Features are not as extensive as AUTOMATIC1111

Diffusers App

Install Instructions

Diffusers is a Mac app made by Hugging Face, the place where many Stable Diffusion models are hosted. You can install the app using the link below.

Link to Diffusers app page

Customizations and available models are pretty limited.

Pros and Cons of Diffusers App

Pros:

  • Easy to install.

Cons:

  • Very limited models and features.

DiffusionBee

In this section, you will learn how to install and run DiffusionBee on Mac step-by-step.

Install DiffusionBee on Mac

DiffusionBee is one of the easiest ways to run Stable Diffusion on Mac. Its installation process is no different from any other app.

Step 1: Go to DiffusionBee’s download page and download the installer for MacOS – Apple Silicon. A dmg file should be downloaded.

Step 2: Double-click to run the downloaded dmg file in Finder. The following windows will show up.

Step 3: Drag the DiffusionBee icon on the left to the Applications folder on the right. Installation is now complete!

Run DiffusionBee on Mac

You can use the spotlight search bar to start StableBee. Press command + spacebar to bring up spotlight search. Type “DiffusionBee” and press return to start DiffusionBee.

It will download some models when it starts for the very first time.

After it is done, you can start using Stable Diffusion! Let’s try putting the prompt “a cat” in the prompt box and hit Generate.

Works pretty well! You can click the option button to customize your images such as image size and CFG scale.

Go to the Next Step section to see what to do next.

Pros and Cons of DiffusionBee

Pros

  • Installation is relatively easy

Cons

  • Features are a bit lacking.

AUTOMATIC1111

This section shows you how to install and run AUTOMATIC1111 on Mac step-by-step.

DiffusionBee is easy to install but the functionality is pretty limited. If you are (or aspired to be) an advanced user, you will want to use an advanced GUI like AUTOMATIC1111. You will need this GUI if you want to follow my tutorials.

Install AUTOMATIC1111 on Mac

Step 1: Install Homebrew, a package manager for Mac, if you haven’t already. Open the Terminal app, type the following command, and press return.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2: Install a few required packages. Open a new terminal and run the following command

brew install cmake protobuf rust [email protected] git wget

Step 3: Clone the AUTOMATIC1111 repository by running the following command in the terminal

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui

A new folder stable-diffusion-webui should be created under your home directory.

Step 5: You will need a model to run Stable Diffusion. Use the following link to download the v1.5 model.

Download link

Put the file in the folder stable-diffusion-webui/models/Stable-diffusion. You can get there in the Finder app. In the top menu, click Go and then Home. Double Click to go to the folder stable-diffusion-webui, and then models, and then Stable-diffusion.

When you are done with this step, the Stable-diffusion folder should have two files like below.

Run AUTOMATIC1111 on Mac

Follow the steps in this section to start AUTOMATIC1111 GUI for Stable Diffusion.

In the terminal, run the following command.

cd ~/stable-diffusion-webui;./webui.sh 

It will take a while when you run it for the very first time.

Open a web browser and click the following URL to start Stable Diffusion.

http://127.0.0.1:7860/

You should see the AUTOMATIC1111 GUI. Put in a prompt “a cat” and press Generate to test using the GUI.

Close the terminal when you are done. Follow the steps in this section the next time when you want to run Stable Diffusion.

Pros and Cons of AUTOMATIC1111

Pros

  • Best features among all apps

Cons

  • Difficult to install if you are not tech-savvy.

Next Steps

Now you are able to run Stable Diffusion, below are some suggestions on what to learn next.


Buy Me A Coffee

13 comments

  1. Hello! thanks for this post… but i have a problem i can’t solve yet. When i try to run the “cd ~/stable-diffusion-webui;./webui.sh”

    this error appears and no matter what i do it wont go, any suggestions on how to fix it?

    Screenshot of the error:
    https://ibb.co/tXdfL91

    1. Hi, I haven’t seen this before. The only thing I can think of is you can check if your OS is update-to-date. I install it successfully on MacOS 13.2.1.
      If that’s not the issue, you can visit a1111’s github page and ask for help there.

  2. Hi Andrew,

    Thanks for the tutorial. It installed ok but when I try to prompt I get this error:
    RuntimeError: “LayerNormKernelImpl” not implemented for ‘Half’

    It’s making me think it’s. not configured for M1 processors…?

    Thanks for any help you can offer

    1. Hi, I just tested installing on a M1 and it works. A few pointers
      1. Did you run webui.sh? It should call a macos script which specifies a “no half” argument.
      2. Any error message when you run webui.sh?

  3. Hello Andrew ! I’ve got this error after launching launch.py:
    File”/usr/local/Cellar/[email protected]/3.10.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py”, line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    ImportError: dlopen(/Users/anna/stable-diffusion-webui/venv/lib/python3.10/site-packages/cv2/cv2.abi3.so, 2): Symbol not found: _VTRegisterSupplementalVideoDecoderIfAvailable
    Referenced from: /Users/anna/stable-diffusion-webui/venv/lib/python3.10/site-packages/cv2/.dylibs/libavcodec.59.37.100.dylib (which was built for Mac OS X 11.0)
    Expected in: /System/Library/Frameworks/VideoToolbox.framework/Versions/A/VideoToolbox
    in /Users/anna/stable-diffusion-webui/venv/lib/python3.10/site-packages/cv2/.dylibs/libavcodec.59.37.100.dylib

    Looks like is missing a file. Any clue why?
    Thanks !

  4. Andrew,
    Thank you for putting this together! I followed your instructions (but maybe failed) and I’m getting a change directory error:
    ./webui.sh: line 105: cd: /home/2022mac14/: No such file or directory
    ERROR: Can’t cd to /home/2022mac14/, aborting…%

    Yet there is a directory – any help is appreciated (clearly a noob)

    1. Hi Rich, the error message looks wrong — the directory should be the stable-diffusion-webui, not your home dir. There’s a chance that something was wrong before this step. You can try restart install the whole thing again.

  5. Everytime I try running it local on my mac book pro I get the following message and the terminal basically stays like this indefinitely for hours. I have no idea how to fix it.

    ==> ./configure –prefix=/usr/local/Cellar/rust/1.67.0 –enable-vendor –set rus
    ==> make

  6. Greetings;
    New at trying to run SD locally on my M2 MacBook… Not new with SD.
    Following is the echo after running the command to do the original initialization/setup etc:
    ——–clipped just after ‘No module ‘xformers’. Proceeding without it.

    You are running torch 1.12.1.
    The program is tested to work with torch 1.13.1.
    To reinstall the desired version, run with commandline flag –reinstall-torch.
    Beware that this will cause a lot of large files to be downloaded.
    ((What directory do I need to be in to successfully run the –reinstall-torch command?))
    ==============================================================================
    Loading weights [b97a0e0676] from /Users/davidfisher/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.ckpt.download/v1-5-pruned-emaonly.ckpt
    Error verifying pickled file from /Users/davidfisher/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.ckpt.download/v1-5-pruned-emaonly.ckpt:
    Traceback (most recent call last):
    File “/Users/davidfisher/stable-diffusion-webui/modules/safe.py”, line 81, in check_pt
    with zipfile.ZipFile(filename) as z:
    File “/opt/homebrew/Cellar/[email protected]/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/zipfile.py”, line 1267, in __init__
    self._RealGetContents()
    File “/opt/homebrew/Cellar/[email protected]/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/zipfile.py”, line 1334, in _RealGetContents
    raise BadZipFile(“File is not a zip file”)
    zipfile.BadZipFile: File is not a zip file

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “/Users/davidfisher/stable-diffusion-webui/modules/safe.py”, line 135, in load_with_extra
    check_pt(filename, extra_handler)
    File “/Users/davidfisher/stable-diffusion-webui/modules/safe.py”, line 102, in check_pt
    unpickler.load()
    _pickle.UnpicklingError: persistent IDs in protocol 0 must be ASCII strings

    —–> !!!! The file is most likely corrupted !!!! <—–
    You can skip this check with –disable-safe-unpickle commandline argument, but that is not going to help you.

    loading stable diffusion model: AttributeError
    Traceback (most recent call last):
    File "/Users/davidfisher/stable-diffusion-webui/webui.py", line 103, in initialize
    modules.sd_models.load_model()
    File "/Users/davidfisher/stable-diffusion-webui/modules/sd_models.py", line 370, in load_model
    state_dict = get_checkpoint_state_dict(checkpoint_info, timer)
    File "/Users/davidfisher/stable-diffusion-webui/modules/sd_models.py", line 228, in get_checkpoint_state_dict
    res = read_state_dict(checkpoint_info.filename)
    File "/Users/davidfisher/stable-diffusion-webui/modules/sd_models.py", line 214, in read_state_dict
    sd = get_state_dict_from_checkpoint(pl_sd)
    File "/Users/davidfisher/stable-diffusion-webui/modules/sd_models.py", line 187, in get_state_dict_from_checkpoint
    pl_sd = pl_sd.pop("state_dict", pl_sd)
    AttributeError: 'NoneType' object has no attribute 'pop'

    Stable diffusion model failed to load, exiting
    ———
    I hate doing this to you but I'm basically stuck.

    1. Hi David, you will need to edit the file webui-macos-env.sh
      There’s a line like

      export COMMANDLINE_ARGS=”–skip-torch-cuda-test –use-cpu interrogate”

      You can add –reinstall-torch to it

      If it does it, you will need to remove it before running again.

Leave a Reply