wy-luke / StableDiffusion-Installer-For-Mac

Install Stable Diffusion on your Mac with one single command. 一条命令为你的 Mac 装上 Stable Diffusion

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

中文   |   English

Stable Diffusion Installer For Mac

Conventional Commits GitHub commit activity (branch) GitHub release (with filter) Test

Install Stable Diffusion web UI on your Mac with one sigle command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/wy-luke/StableDiffusion-Installer-For-Mac/main/sd-installer.sh)"

Use mamba to create virtual environment, so it won't conflict with and won't pollute the Python environment in your system. Keep your Mac system untouched. And the uninstallation script is on the way.

Theoretically, it should work on both Apple Silicon and Intel CPU with any version of macOS.

If you encounter any issues or want some new features, feel free to contact me via here.

Detailed usage

  1. In the Applications folder, locate Terminal terminal and open it.

    Note: It's in the /Applications/Utilities folder. If you still can't find it, search it by name!

  2. Copy the following command to the terminal, press the Enter key to execute the command, and the installation will start automatically. Just wait for the installation to complete.

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/wy-luke/StableDiffusion-Installer-For-Mac/main/sd-installer.sh)"
  3. At the beginning, you will be prompted to enter password, just type your login password.

    Note: Your password will be invisible when you type, just type it, and press Enter after completion.

  4. If you see similar content below, it indicates a successful installation.

    success

  5. Open your web browser and enter http://127.0.0.1:7860 (the underlined part in the image above) to access the Stable Diffusion web UI.

    Note 1: Normally, it will automatically open the web browser.

    Note 2: Don't close the terminal app while using Stable Diffusion web UI, just keep it running background. If you accidentally close the terminal, see Re-run section below.

  6. If the installation fails, you will be prompted to select whether to retry. Type y or just simply press the Enter key to try again. Type n to exit.

Re-run

Keep the terminal running while using SD. When you don't use it anymore, just close the brower page and the terminal.

If you want to re-run SD after the first usage, use the command below to re-run Stable Diffusion web UI.

/bin/bash $HOME/stable-diffusion-webui/webui.sh

If you move the stable-diffusion-webui folder to another path, you need to change the command above accordingly. Besides, you need always append /webui.sh in the end.

/bin/bash /your/path/of/stable-diffusion-webui/webui.sh

Troubleshooting

**** not implemented for 'Half'

Most likely, this is due to poor compatibility with AMD graphics cards.

The solution is simple. Run the command below, then execute the re-run command above again to start SD.

echo 'export COMMANDLINE_ARGS="--upcast-sampling --no-half-vae --use-cpu interrogate --precision full --no-half --skip-torch-cuda-test"' > $HOME/stable-diffusion-webui/webui-user.sh

MPS backend out of memory

This issue is caused by insufficient memory. You can reduce the memory requirement by adding PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.7 before the re-run command to make SD run correctly.

Note: This will result in longer processing time to generate a image. You could adjust the value of PYTORCH_MPS_HIGH_WATERMARK_RATIO according to your mac performance.

Replace the re-run command with:

PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.7 /bin/bash $HOME/stable-diffusion-webui/webui.sh

If you still encounter this issue, you can try further reducing the value, such as:

PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.5 /bin/bash $HOME/stable-diffusion-webui/webui.sh

Download models

Place the models downloaded to stable-diffusion-webui/models/Stable-diffusion folder. Then refresh the Stable Diffusion web UI page in the browser and you will see it in the list.

  1. You could download all kinds of models in Civitai, a great site!

  2. Some popular official Stable Diffusion 1.x models:

  3. Stable Diffusion 2.0 and 2.1 models:

    These models require both a model and a configuration file, and image width & height will need to be set to 768 or higher when generating images.

    For the configuration file, hold down the option key on the keyboard and click here to download v2-inference-v.yaml (it may download as v2-inference-v.yaml.yml). In Finder select that file then go to the menu and select File > Get Info. In the window that appears select the filename and change it to the filename of the model, except with the file extension .yaml instead of .ckpt, press return on the keyboard (confirm changing the file extension if prompted), and place it in the same folder as the model

    E.g. if you downloaded the 768-v-ema.ckpt model, rename it to 768-v-ema.yaml and put it in stable-diffusion-webui/models/Stable-diffusion along with the model.

    Download the v2-midas-inference.yaml configuration file by holding down option on the keyboard and clicking here, then rename it with the .yaml extension in the same way as mentioned above and put it in stable-diffusion-webui/models/Stable-diffusion along with the model. Note that this model works at image dimensions of 512 width/height or higher instead of 768.

Features

  1. Use Homebrew to install required dependencies. If you already have it installed, it will be used automatically. If not, it will be installed for you, but without modifying your system environment – your system will remain unchanged.

    If you wish to activate it by default, you can add eval $(/opt/homebrew/bin/brew shellenv) to your .zprofile (zsh) or .bash_profile (bash) file.

    You could also:

    # zsh
    echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/$USER/.zprofile
    eval $(/opt/homebrew/bin/brew shellenv)
    
    # bash
    echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/$USER/.bash_profile
    eval $(/opt/homebrew/bin/brew shellenv)
  2. Use micromamba, which is a tiny version of the mamba, as Python related package and environment manager instead of Conda.

    Compared to Conda, it has no base environment (empty) nor default version of Python, meaning that it won't interfere or contaminate your system's Python environment at all. Additionally, it's significantly faster.

    Similarly, it isn't added to the system environment either, and won't be activated automatically by default.

    But if you want, you could:

    # zsh
    /opt/homebrew/bin/micromamba shell init -s zsh -p ~/micromamba
    source ~/.zshrc
    
    # bash
    /opt/homebrew/bin/micromamba shell init -s bash -p ~/micromamba
    source ~/.bashrc

Credit

AUTOMATIC1111 and stable-diffusion-webui

Homebrew

Mamba

About

Install Stable Diffusion on your Mac with one single command. 一条命令为你的 Mac 装上 Stable Diffusion


Languages

Language:Shell 99.4%Language:JavaScript 0.6%