This page looks best with JavaScript enabled

How to Run Stable Diffusion on macOS Without a GPU

 ·  ☕ 2 min read
  • Memory: at least 16 GB DDR4 or DDR5
  • Storage: at least 10 GB of free space
  • GPU: an NVIDIA card with at least 6 GB of VRAM

If your hardware falls short, you can also use one of the various optimized forks that support lower-spec hardware, but generation time will increase.

The current development machine is configured as:

  • 2.9 GHz 8-Core Intel Core i7
  • 16 GB 2666 MHz DDR4
  • 250 GB SSD

Since there is no GPU, you need to wait a while longer when generating images.

2. Running Stable Diffusion on macOS

  • Install anaconda
1
brew install --cask anaconda
  • Configure PATH
1
echo 'export PATH=/usr/local/anaconda3/bin:$PATH' >> ~/.zshrc
  • Initialize conda for the shell
1
conda init zsh

Here you need to close the window and log into Terminal again.

  • Download and enter the project directory
1
2
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd stable-diffusion-webui
  • Create a Python environment
1
conda create -n stabel python=3.10.6
  • Activate the Python environment and install dependencies
1
2
conda activate stabel
pip3 install -r requirements_versions.txt
  • Download the model

Go to https://huggingface.co/CompVis/stable-diffusion-v-1-4-original and download the sd-v1-4.ckpt or sd-v1-4-full-ema.ckpt file, then place it under the models/Stable-diffusion directory. There are also many other models on huggingface you can download and use, and you can try them online too. For example https://huggingface.co/spaces/IDEA-CCNL/Taiyi-Stable-Diffusion-Chinese .

  • Modify the runtime parameters to skip the GPU check, see [1]
1
export COMMANDLINE_ARGS="--lowvram --precision full --no-half --skip-torch-cuda-test --listen --port 7860"
  • Run the project
1
python launch.py

Visit http://127.0.0.1:7860 locally to open the UI.

If you see an error like stderr: Running command git clone --filter=blob:none --quiet https://github.com/mlfoundations/open_clip.git at startup, you can edit launch.py, find the def prepare_environment() function, and change git+https://https://github.com/ to git+https://github.com/.

3. Text-to-Image Test

There are many writing techniques, sentence patterns, and modifiers for Prompts; Stable Diffusion also has many parameters you can adjust. But this post is mainly about running Stable Diffusion on macOS without a GPU, so here we just enter bird for the test. The generated image is shown below:

4. References

  1. https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/1742

WeChat Official Account
WRITTEN BY
WeChat Official Account