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

Updated Categorized as Tutorial Tagged 133 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.

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, run Stable Diffusion on Google Colab using AUTOMATIC1111 Stable Diffusion WebUI. Check the Quick Start Guide for details.

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

Hardware requirements

You will need a Mac with Apple Silicon (M1 or M2) for reasonable speed.

Recommended CPUs are: M1, M1 pro, M1 max, M2, M2 pro and M2 max. In addition to the efficient cores, the performance cores are important for Stable Diffusion’s performance.

The computer’s form factor doesn’t really matter. It can be a Macbook Air, Macbook Pro, Mac Mini, iMac, Mac Studio, or Mac Pro.

Ideally, your machine will have 16 GB of memory or more.

Stable Diffusion, like many AI models, runs slower on Mac. A similarly priced Windows PC with a dedicated GPU will deliver an image faster.

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 4: 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 --no-half

It will take a while to run it for the 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.

Updating AUTOMATIC1111 Web-UI

Your AUTOMATIC1111 won’t be automatically updated. You will miss new features if you don’t upgrade it periodically. However, there’s always a risk of breaking things every time you update.

To update AUTOMATIC1111, first open the Terminal App.

Go into the AUTOMATIC1111 Web-UI’s folder.

cd ~/stable-diffusion-webui

Lastly, update the software by pulling the latest codes.

git pull

Run AUTOMATIC1111 to see if it’s working properly. If you experience issues, delete the venv folder inside the stable-diffusion-webui folder and restart again.

Pros and Cons of AUTOMATIC1111

Pros

  • Best features among all apps

Cons

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

Frequently Asked Questions

Does AUTOMATIC1111 on Mac support SDXL?

Yes! You will need to update your AUTOMATIC1111 if you have not done it recently. Just do a git pull. See the SDXL tutorial for downloading the model.

I got the error “urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>” when generating images

Press Command+Space to bring up Spotlight search.

 Search for

Install Certificates.command

Open and run it. If will tell you which Python version you ran. Make sure you have run Python 3.10.

I got “RuntimeError: Cannot add middleware after an application has started”

If you get the following error:

File “/Users/XXXXX/stable-diffusion-webui/venv/lib/python3.10/site-packages/starlette/applications.py”, line 139, in add_middleware
raise RuntimeError(“Cannot add middleware after an application has started”)
RuntimeError: Cannot add middleware after an application has started

This is caused by an outdated fastapi package. Run the following command in the webui folder.

./venv/bin/python -m pip install --upgrade fastapi==0.90.1

I got RuntimeError: “LayerNormKernelImpl” not implemented for ‘Half’

Start the webUI with the following command.

./webui.sh --precision full --no-half

When running v2-1_768-ema-pruned.ckpt model, the I got the error: “modules.devices.NansException: A tensor with all NaNs was produced in Unet. This could be either because there’s not enough precision to represent the picture, or because your video card does not support half type. Try setting the “Upcast cross attention layer to float32″ option in Settings > Stable Diffusion or using the –no-half commandline argument to fix this. Use –disable-nan-check commandline argument to disable this check.”

Start webUI with the following command to remove this error.

./webui.sh --no-half

However, as of July 2023, the v2.1 768 model does not produce sensible images.

Web options to run AUTOMATIC1111

Consider the following options for running Stable Diffusion without installing it locally.

(I earn a small commission if you subscribe.)

Graviti Diffus

Graviti Diffus lets you use AUTOMATIC1111 without having a GPU. The service is provided remotely. Use this link to get 20% more credits.

Next Steps

Now you can run Stable Diffusion; below are some suggestions on what to learn next.


If you find the content helpful, please support this site by becoming a member.

Buy Me A Coffee

By Andrew

Andrew is an experienced engineer with a specialization in Machine Learning and Artificial Intelligence. He is passionate about programming, art, photography, and education. He possesses a Ph.D. in engineering.

133 comments

  1. Hey Andrew,

    So I’ve followed your tutorials extensively and have been an extremely avid user of Midjourney for a while.

    Been trying to download SD on my Mac but it’s been a massive pain.

    Your tutorial worked except everytime I try to generate it says ‘connection errored out’ on the web portal

    Is there absolutely any way I can

    1. Get fast generations locally
    2. Just use the system properly without errors

    Mucho gracias for your great work
    Eager to hear from you.

    1. There could be many unforeseen issues running SD locally. I cannot comment without seeing the error message on the terminal.

      But generally using Mac is not ideally because the whole thing is optimized around NVIDIA GPU. For fast local generation, the best option is to get a windows PC with a 4 series NVIDIA card.

  2. Hi there! After following instructions on an Intel MacBook Pro, I’m getting this error four times: “Error
    Connection errored out.” when I write a prompt and click on “Generate”. Any suggestion? Many thanks!

  3. Greetings,
    Thanks for your tutorial. I haven’t got it working yet. I have this error, if you could help me i would be inmensely thankful. Everything is okay, but when it gets to the following line:

    File “/Users/luis/stable-diffusion-webui/venv/lib/python3.10/site-packages/transformers/utils/import_utils.py”, line 1088, in _get_module

    Then it shows this:

    raise RuntimeError(
    RuntimeError: Failed to import transformers.models.auto because of the following error (look up to see its traceback):
    dlopen(/Users/luis/stable-diffusion-webui/venv/lib/python3.10/site-packages/sentencepiece/_sentencepiece.cpython-310-darwin.so, 2): Symbol not found: ____chkstk_darwin
    Referenced from: /Users/luis/stable-diffusion-webui/venv/lib/python3.10/site-packages/sentencepiece/_sentencepiece.cpython-310-darwin.so
    Expected in: /usr/lib/libSystem.B.dylib
    in /Users/luis/stable-diffusion-webui/venv/lib/python3.10/site-packages/sentencepiece/_sentencepiece.cpython-310-darwin.so

    I look forward for an answer, thanks a lot!

    1. Btw I have macOS 10.13.6 high sierra and i cannot upgrade no more since my mac is old (mid 2012). This has caused me a lot of trouble, like not being able to install the latest xcode or some installs just like this one. This happens to me in this step:

      cd ~/stable-diffusion-webui;./webui.sh –no-half

      Please i would love to use this in my mac. Help would be inmensely appreciated.

  4. I got the same error:

    ../../scipy/meson.build:159:9: ERROR: Dependency “OpenBLAS” not found, tried pkgconfig, framework and cmake

    did you find a solution?

    1. I just re-install on Mac M1. It works successfully. I don’t see scikit-image being installed.

      Few questions:
      1. Can you confirm you are using M1 or M2?
      2. Confirm there’s no extensions installed. ie. Delete all folders in the extensions folder.

    1. Try running “git pull” to update your webui. Delete the venv folder and run webui.sh again.

      If that doesn’t work, try removing folders in extensions and restart the above process.

  5. Wow thank you very muche for your answer :

    ################################################################
    Install script for stable-diffusion + Web UI
    Tested on Debian 11 (Bullseye)
    ################################################################

    ################################################################
    Running on juliensallerin user
    ################################################################

    ################################################################
    Repo already cloned, using it as install directory
    ################################################################

    ################################################################
    Create and activate python venv
    ################################################################

    ################################################################
    Launching launch.py…
    ################################################################
    Python 3.10.6 (v3.10.6:9c7b4bd164, Aug 1 2022, 17:13:48) [Clang 13.0.0 (clang-1300.0.29.30)]
    Version: v1.5.1
    Commit hash: 68f336bd994bed5442ad95bad6b6ad5564a5409a
    Installing gfpgan
    Traceback (most recent call last):
    File “/Users/juliensallerin/stable-diffusion-webui/launch.py”, line 39, in
    main()
    File “/Users/juliensallerin/stable-diffusion-webui/launch.py”, line 30, in main
    prepare_environment()
    File “/Users/juliensallerin/stable-diffusion-webui/modules/launch_utils.py”, line 320, in prepare_environment
    run_pip(f”install {gfpgan_package}”, “gfpgan”)
    File “/Users/juliensallerin/stable-diffusion-webui/modules/launch_utils.py”, line 136, in run_pip
    return run(f'”{python}” -m pip {command} –prefer-binary{index_url_line}’, desc=f”Installing {desc}”, errdesc=f”Couldn’t install {desc}”, live=live)
    File “/Users/juliensallerin/stable-diffusion-webui/modules/launch_utils.py”, line 113, in run
    raise RuntimeError(“\n”.join(error_bits))
    RuntimeError: Couldn’t install gfpgan.
    Command: “/Users/juliensallerin/stable-diffusion-webui/venv/bin/python3.10” -m pip install https://github.com/TencentARC/GFPGAN/archive/8d2447a2d918f8eba5a4a01463fd48e45126a379.zip –prefer-binary
    Error code: 1
    stdout: Collecting https://github.com/TencentARC/GFPGAN/archive/8d2447a2d918f8eba5a4a01463fd48e45126a379.zip
    Using cached https://github.com/TencentARC/GFPGAN/archive/8d2447a2d918f8eba5a4a01463fd48e45126a379.zip (6.0 MB)
    Installing build dependencies: started
    Installing build dependencies: finished with status ‘done’
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status ‘done’
    Installing backend dependencies: started
    Installing backend dependencies: finished with status ‘done’
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status ‘done’
    Collecting basicsr>=1.4.2 (from gfpgan==1.3.5)
    Using cached basicsr-1.4.2.tar.gz (172 kB)
    Installing build dependencies: started
    Installing build dependencies: finished with status ‘done’
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status ‘done’
    Installing backend dependencies: started
    Installing backend dependencies: finished with status ‘done’
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status ‘done’
    Collecting facexlib>=0.2.5 (from gfpgan==1.3.5)
    Using cached facexlib-0.3.0-py3-none-any.whl (59 kB)
    Collecting lmdb (from gfpgan==1.3.5)
    Using cached lmdb-1.4.1.tar.gz (881 kB)
    Installing build dependencies: started
    Installing build dependencies: finished with status ‘done’
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status ‘done’
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status ‘done’
    Requirement already satisfied: numpy in ./venv/lib/python3.10/site-packages (from gfpgan==1.3.5) (1.25.2)
    Collecting opencv-python (from gfpgan==1.3.5)
    Obtaining dependency information for opencv-python from https://files.pythonhosted.org/packages/32/a6/4321f0f30ee11d6d85f49251d417f4e885fe7638b5ac50b7e3c80cccf141/opencv_python-4.8.0.76-cp37-abi3-macosx_11_0_arm64.whl.metadata
    Downloading opencv_python-4.8.0.76-cp37-abi3-macosx_11_0_arm64.whl.metadata (19 kB)
    Collecting pyyaml (from gfpgan==1.3.5)
    Obtaining dependency information for pyyaml from https://files.pythonhosted.org/packages/5b/07/10033a403b23405a8fc48975444463d3d10a5c2736b7eb2550b07b367429/PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl.metadata
    Downloading PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl.metadata (2.1 kB)
    Collecting scipy (from gfpgan==1.3.5)
    Using cached scipy-1.11.2.tar.gz (56.0 MB)
    Installing build dependencies: started
    Installing build dependencies: finished with status ‘done’
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status ‘done’
    Installing backend dependencies: started
    Installing backend dependencies: finished with status ‘done’
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status ‘error’

    stderr: error: subprocess-exited-with-error

    × Preparing metadata (pyproject.toml) did not run successfully.
    │ exit code: 1
    ╰─> [43 lines of output]
    + meson setup /private/var/folders/m4/9j34tlks2zq2_xrnkn5jnnxw0000gn/T/pip-install-6o1b36a3/scipy_364cf24d69844dad8d45f84a032eb618 /private/var/folders/m4/9j34tlks2zq2_xrnkn5jnnxw0000gn/T/pip-install-6o1b36a3/scipy_364cf24d69844dad8d45f84a032eb618/.mesonpy-ksiupg1j/build -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md –native-file=/private/var/folders/m4/9j34tlks2zq2_xrnkn5jnnxw0000gn/T/pip-install-6o1b36a3/scipy_364cf24d69844dad8d45f84a032eb618/.mesonpy-ksiupg1j/build/meson-python-native-file.ini
    The Meson build system
    Version: 1.2.1
    Source dir: /private/var/folders/m4/9j34tlks2zq2_xrnkn5jnnxw0000gn/T/pip-install-6o1b36a3/scipy_364cf24d69844dad8d45f84a032eb618
    Build dir: /private/var/folders/m4/9j34tlks2zq2_xrnkn5jnnxw0000gn/T/pip-install-6o1b36a3/scipy_364cf24d69844dad8d45f84a032eb618/.mesonpy-ksiupg1j/build
    Build type: native build
    Project name: SciPy
    Project version: 1.11.2
    C compiler for the host machine: cc (clang 13.0.0 “Apple clang version 13.0.0 (clang-1300.0.29.30)”)
    C linker for the host machine: cc ld64 711
    C++ compiler for the host machine: c++ (clang 13.0.0 “Apple clang version 13.0.0 (clang-1300.0.29.30)”)
    C++ linker for the host machine: c++ ld64 711
    Cython compiler for the host machine: cython (cython 0.29.36)
    Host machine cpu family: aarch64
    Host machine cpu: aarch64
    Program python found: YES (/Users/juliensallerin/stable-diffusion-webui/venv/bin/python3.10)
    Found pkg-config: /opt/homebrew/bin/pkg-config (0.29.2)
    Run-time dependency python found: YES 3.10
    Program cython found: YES (/private/var/folders/m4/9j34tlks2zq2_xrnkn5jnnxw0000gn/T/pip-build-env-o3n9g62l/overlay/bin/cython)
    Compiler for C supports arguments -Wno-unused-but-set-variable: NO
    Compiler for C supports arguments -Wno-unused-function: YES
    Compiler for C supports arguments -Wno-conversion: YES
    Compiler for C supports arguments -Wno-misleading-indentation: YES
    Library m found: YES
    Fortran compiler for the host machine: gfortran (gcc 13.1.0 “GNU Fortran (Homebrew GCC 13.1.0) 13.1.0”)
    Fortran linker for the host machine: gfortran ld64 711
    Compiler for Fortran supports arguments -Wno-conversion: YES
    Checking if “-Wl,–version-script” : links: NO
    Program pythran found: YES (/private/var/folders/m4/9j34tlks2zq2_xrnkn5jnnxw0000gn/T/pip-build-env-o3n9g62l/overlay/bin/pythran)
    Found CMake: /opt/homebrew/bin/cmake (3.27.4)
    WARNING: CMake Toolchain: Failed to determine CMake compilers state
    Run-time dependency xsimd found: NO (tried pkgconfig, framework and cmake)
    Run-time dependency threads found: YES
    Library npymath found: YES
    Library npyrandom found: YES
    pybind11-config found: YES (/private/var/folders/m4/9j34tlks2zq2_xrnkn5jnnxw0000gn/T/pip-build-env-o3n9g62l/overlay/bin/pybind11-config) 2.10.4
    Run-time dependency pybind11 found: YES 2.10.4
    Run-time dependency openblas found: NO (tried pkgconfig, framework and cmake)
    Run-time dependency openblas found: NO (tried pkgconfig, framework and cmake)

    ../../scipy/meson.build:159:9: ERROR: Dependency “OpenBLAS” not found, tried pkgconfig, framework and cmake

    A full log can be found at /private/var/folders/m4/9j34tlks2zq2_xrnkn5jnnxw0000gn/T/pip-install-6o1b36a3/scipy_364cf24d69844dad8d45f84a032eb618/.mesonpy-ksiupg1j/build/meson-logs/meson-log.txt
    [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed

    × Encountered error while generating package metadata.
    ╰─> See above for output.

    note: This is an issue with the package mentioned above, not pip.
    hint: See above for details.

    zsh: command not found: –no-half

  6. When i launch for the first time webui.sh
    It stops when installing Installing gfpgan

    × Preparing metadata (pyproject.toml) did not run successfully.
    │ exit code: 1
    ╰─> [43 lines of output]
    Do you know how to fix it?
    i try for several days to fix it.
    Any help would be appreciate ^^

  7. Very low quality results, very disappointing, especially since I couldn’t find it in the Apple Store. I’m always very hesitant downloading un-approved software, now I wish I hadn’t downloaded it.

  8. I can’t seem to run the model. When to try to run ./webui.sh –no-half, I get an error:

    —————-
    File “/Users/mark./Dev/stable-diffusion-webui/venv/lib/python3.10/site-packages/omegaconf/basecontainer.py”, line 73, in _get_child
    child = self._get_node(
    File “/Users/mark./Dev/stable-diffusion-webui/venv/lib/python3.10/site-packages/omegaconf/dictconfig.py”, line 480, in _get_node
    raise ConfigKeyError(f”Missing key {key!s}”)
    omegaconf.errors.ConfigAttributeError: Missing key model
    full_key: model
    object_type=dict

    Stable diffusion model failed to load
    —————-

    Also, earlier in the build process it says: “Warning: caught exception ‘Torch not compiled with CUDA enabled’, memory monitor disabled”

    Any ideas how it could be resolved?

Leave a comment

Your email address will not be published. Required fields are marked *