Stable Diffusion setup for Apple Silicon-based Macs

If you're one of the few people that have not yet got a local version of Stable Diffusion up and running – and you have a computer with an Apple Silicon based processor – I've got something for you...

The following bash script will set up a local conda-environment ("m1sd"), along with any and all dependencies – including Homebrew and Conda, if they are not already installed on your system.

It'll pause once and ask you to perform the one necessary manual step necessary (the download-portion of which can take a little time) before continuing at your request.

It'll also remove the built-in NSFW-filter (which is a little trigger-happy, IMO), so you won't get rickrolled by the machine learning model.

Run this script in a folder you'd like to set up Stable Diffusion in:

#!/bin/env bash

if ! brew &> /dev/null
    /bin/bash -c "$(curl -fsSL"

if ! which conda &> /dev/null
    brew install conda

git clone -b apple-silicon-mps-support m1-stable-diffusion
cd m1-stable-diffusion

brew install Cmake protobuf rust

conda create --name m1sd python==3.10
conda activate m1sd
pip install -r requirements.txt

mkdir -p models/ldm/stable-diffusion-v1/

echo ""
echo "Now you need to do the following:"
echo "    - Set up an account on"
echo "    - Go to and agree to the license."
echo "    - Download the file named \"sd-v1-4.ckpt\"; save it to $FOLDER as \"model.ckpt\""
read -p "Press enter to continue"
echo ""

#remove NSFW filter
cp scripts/ scripts/
sed -i ''  's/x_checked_image, has_nsfw_concept = check_safety(x_samples_ddim)/x_checked_image = x_samples_ddim/g' scripts/
awk '/# load safety model/ {suppress=1} /^\s*$/ {suppress=0} !suppress' scripts/ > scripts/ && mv -f scripts/ scripts/
cd -
cd ..

I'll probably host a proper installation script later; For now, just run the commands above, and you should be up and running in no time!

Older post
AppSec Village DEF CON 29 CTF Writeup