3 ways to Install and run Stable Diffusion locally on your Mac (M1, M2)

Install and run stable diffusion locally on your mac

This article will show how to install and use Stable Diffusion locally on your Mac in the easiest possible ways.

Stable Diffusion has taken the AI-generated art and images domain by storm. And for good reasons.

It’s Open Source, it’s free and anyone can use it the way they want it and wherever they want to use it.

And unlike DALL-E, you can install and run it locally.

Right now, there are so many different ways to install it on Mac machines.

We will cover GUI-based installers like Diffusion Bee and CHARL-E and also a hands-on method using the command line. Let’s go.

Via Diffusion Bee, a GUI App for installing Stable Diffusion on your Mac

Diffusion Bee is the easiest way to install and run Stable Diffusion locally on your Mac.

It comes with a one-click installer in the form of a typical Mac binary – dmg package.

No dependencies or technical knowledge is needed to install Diffusion Bee.

You can run it locally on your computer. Your prompts or your generated images are not sent to any 3-rd party.

And it’s free.

Requirements to install Diffusion Bee

  • You should have an M1  or M2-based Mac. If you have an older machine, try this method
  • 16 GB or higher RAM is preferred and it will really well with that. However, it will install and run on 8GB RAM but is a bit slower when generating images. At least that’s something more than nothing, huh? 🙂
  • You should have OS MacOS 12.5.1 or later on your Mac.

Let’s get to installing and using it then.

  1. Download Diffusion Bee
  2. Open the downloaded dmg file.
  3. Double click on the App inside it to start the Stable Diffusion Mac application
  4. Enter your text prompt and press generate – You will see your generated images in a few seconds.

Run Stable Diffusion via installing CHARL-E

  1. Visit CHARL-E website
  2. Download CHARL-E – currently the app package is around ~ 300 MB
  3. Once you launch the app, it will automatically download ll dependencies, including the Stable Diffusion code.

Installing Stable Diffusion on your Mac via the command line

Requirements

  • You need a Mac with an M1 or M2 chip with Mac OS 12.3 or newer installed. The method described in this article will not work with older machines.
  • This method requires you to work in the command line program. No coding knowledge is required but should be able to know how to run commands in the Terminal.

That’s all you need to run Stable Diffusion locally on your Mac. Let’s get to it then.

Steps to install Stable Diffusion locally on your Mac

  1. Open Terminal App on your Mac
  2. Check if Python 3 or higher is installed by running the command python -v
  3. If Python 3 or higher is installed, go to the next step. Other you would need to install it. In order to install Python, use the below command in succession.
      1. brew update
      2. brew install python
  4. Install some supporting modules by running the below commands
      1. brew install cmake protobuf rust
  5. Get Stable Diffusion by running the below command in succession.
      1. git clone -b apple-silicon-mps-support https://github.com/bfirsh/stable-diffusion.git
      2. cd stable-diffusion
      3. mkdir -p models/ldm/stable-diffusion-v1/
      4. pip install -r requirements.txt
  6. Open this Stable Diffusion page.
  7. Read the license on the above page.
  8. If you accept the terms, click “Access repository”.
  9. Then Download the file sd-v1-4.ckpt linked from the page.
  10. Let’s say the download file is in your Downloads folder. Copy it to your Stable Diffusion folder using Terminal.
    cp ~/Downloads/sd-v1-4.ckpt models/ldm/stable-diffusion-v1/model.ckpt

That’s it. If all these steps are run successfully, you now have Stable Diffusion installed and ready to be used locally on your Mac.

Running Stable Diffusion locally on your Mac

Make sure you are still in the root folder of Stable Diffusion from the Terminal App.

Run the below command to generate your first AI art

  python scripts/txt2img.py --prompt "An Astronaut riding a horse on the Moon"  --n_samples 1 --n_iter 1 --plms

 

Replace the prompt in double quotes with your own text prompt and run again.

References