sodcalculator

10 Tech How-To

Local Image Generation on Mac: Step-by-Step Setup

Guide 10-28224 · Updated · Step by step

Setting up local image generation on a Mac lets you create AI images without sending prompts to cloud services, keeping your work private and free from usage limits. This guide walks you through installing a stable diffusion environment, downloading a model, and generating your first image—all from your Mac’s Terminal. You’ll need a Mac with at least 8 GB of RAM (16 GB recommended), macOS 12 or later, and about 15 GB of free storage for the software and models.

What You’ll Need

  • A Mac running macOS Monterey (12) or newer, ideally with an Apple Silicon (M1/M2/M3) chip for best performance.
  • At least 8 GB of RAM (16 GB or more is recommended for larger models).
  • About 15 GB of free disk space for the software and default model.
  • Command Line Tools for Xcode (installed via Terminal).
  • Homebrew (a package manager for macOS) installed.

Step-by-Step

  1. Install Command Line Tools
    Open Terminal (found in /Applications/Utilities/). Run the following command and click “Install” when prompted:
    xcode-select --install
  2. Install Homebrew
    If you don’t already have Homebrew, paste this into Terminal and press Enter:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    Follow the on-screen prompts. After it finishes, run brew --version to confirm.
  3. Install Python and Git
    Homebrew makes this easy. Run:
    brew install python git
  4. Create a Project Folder
    Decide where you want your image generation setup. For example:
    mkdir ~/ai-images && cd ~/ai-images
  5. Clone a Stable Diffusion WebUI
    The most popular choice is AUTOMATIC1111’s Stable Diffusion WebUI. Run:
    git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
    Then enter the folder:
    cd stable-diffusion-webui
  6. Set Up a Virtual Environment (Recommended)
    This keeps dependencies isolated. Run:
    python3 -m venv venv
    source venv/bin/activate
  7. Install Dependencies
    Run the setup script. This may take 10–20 minutes:
    ./webui.sh
    This installs PyTorch and other required packages. If you see errors, see Troubleshooting below.
  8. Download a Model
    By default, the WebUI doesn’t include a model. You need to download one from a site like Hugging Face or CivitAI. A good starting point is Stable Diffusion 1.5. Place the downloaded .safetensors file into the models/Stable-diffusion folder inside your project directory.
  9. Launch the WebUI
    Still in the project folder, run:
    ./webui.sh
    After a few moments, you’ll see a local URL like http://127.0.0.1:7860. Open it in your browser.
  10. Generate Your First Image
    In the web interface, type a prompt like “a red apple on a wooden table, photorealistic” and click “Generate.” The image will appear after a few seconds to a minute, depending on your Mac.

Common Mistakes

  • Forgetting to activate the virtual environment—if you close Terminal and reopen it, you must run source venv/bin/activate again before launching the WebUI.
  • Putting the model in the wrong folder—the WebUI looks for models in models/Stable-diffusion, not the root folder.
  • Using an incompatible model version—some models are for SD 2.x or SDXL and may not work with the default settings. Stick to SD 1.5 for your first try.
  • Ignoring system requirements—trying to run on a Mac with 8 GB RAM may cause slow generation or crashes. Close other apps to free memory.
  • Skipping the Xcode Command Line Tools—many build steps fail without them.

Tips

  • Use --medvram flag when launching if you have 8 GB RAM: ./webui.sh --medvram.
  • For better performance on Apple Silicon, ensure you have the latest macOS updates; PyTorch uses the Metal backend for GPU acceleration.
  • Experiment with negative prompts (e.g., “blurry, low quality”) to improve results.
  • Save your generated images to a folder you can easily access; the WebUI saves them in outputs/txt2img-images.
  • Use the “Seed” field to reproduce a specific image—keep the same seed and prompt to get the same result.

Troubleshooting

WebUI fails to start with a “No module named torch” error
This usually means the virtual environment isn’t active or the installation didn’t complete. Run source venv/bin/activate and then pip install torch torchvision torchaudio manually, then try ./webui.sh again.

Generation is extremely slow or crashes
Reduce the image resolution (e.g., 512×512 instead of 1024×1024) and use --medvram. Also close other apps to free RAM.

“RuntimeError: MPS backend out of memory”
Lower the batch size to 1 and reduce image dimensions. If the problem persists, use --lowvram flag.

Browser shows “Connection refused”
Make sure the Terminal window where you ran ./webui.sh is still open. The WebUI must be running to access the URL.

Model not appearing in the dropdown
Refresh the page and check that the model file is in the correct folder with a .safetensors or .ckpt extension.

Frequently Asked Questions

Can I run this on an Intel Mac?
Yes, but it will be slower. Intel Macs don’t support Metal acceleration as effectively, so expect longer generation times.

How much does it cost to run locally?
Nothing beyond electricity. The software and models are free to use.

Is it legal to use any model I download?
Check the license of each model. Most are for personal use, but some have restrictions on commercial use.

Can I use my own photos to train a model?
Yes, but that’s advanced. You’d need to use tools like Dreambooth, which require additional setup.

Why is my image quality lower than online services?
Local models can produce high quality, but you may need to tweak settings like steps, CFG scale, and sampler. Try increasing steps to 30 or 40.

Can I generate images without the web interface?
Yes, you can use the command line directly, but the WebUI is easier for beginners.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →