Try   HackMD

如何在Mac上安裝Stable Diffusion?

AUTOMATIC1111官方安裝文件_Installation on Apple Silicon

我的Mac規格

  • CPU: M2 Air, 8核
  • Memory: 24GB
  • MacOS: Ventura 13.4.1
  • GPU: 8核

Mac怎麼看幾核?
左上小的小蘋果->關於這台Mac->更多資訊->一般->關於最下方的系統報告->硬體就會有CPU核數,而顯示卡/顯示器就會有GPU核數

安裝Homebrew

Homebrew

安裝Homebrew

打開終端機,執行以下指令。

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

將Homebrew增加進PATH

在終端機,執行以下指令。

  • 這個命令會將 eval "$(/opt/homebrew/bin/brew shellenv)" 添加到 /Users/daistella/.zprofile 文件的末尾。
  • .zprofile 是當您啟動終端機時會執行的 shell 設定文件之一。
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/daistella/.zprofile

接著,輸入並執行以下指令。

  • 立即在當前的 shell session 中加入 Homebrew 到您的 PATH。
eval "$(/opt/homebrew/bin/brew shellenv)"

測試是否可以在終端機中直接使用 Homebrew 命令。

  • 如果看到 Homebrew 的版本號顯示在終端機中,那麼表示您已成功設置並可以直接使用 Homebrew 命令。
brew --version

安裝一些基本開發套件

打開新終端機,執行以下指令。

  • Stable Diffusion WebUI 僅支援 python 3.10 ,其他版本可能會有問題。
brew install cmake protobuf rust python@3.10 git wget

下載Stable Diffusion WebUI

  • 建立一個新資料夾,如sd。
  • 點擊鍵盤的option,並點擊該資料夾sd右鍵"拷背「sd」作為路徑名稱"。
  • cd進入該資料夾。
cd /Users/daistella/Documents/sd
  • 從github複製Stable Diffusion WebUI的檔案。
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui

下載Stable Diffusion模型

Downloading Stable Diffusion Models

  • 下載Stable Diffusion 1.5: v1-5-pruned.ckpt
  • 將ckpt檔放到以下資料夾位置: stable-diffusion-webui/models/Stable-diffusion

其他模型下載: Civitai, Hugging Face

啟動Stable Diffusion

  • 進入Stable Diffusion WebUI資料夾,執行webui.sh
  • 第一次啟動時會建立虛擬環境及安裝必要套件。
cd stable-diffusion-webui
./webui.sh
  • 用瀏覽器連 http://127.0.0.1:7860 進入Stable Diffusion WebUI。
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →
  • 看到以下畫面表示成功啟動Stable Diffusion WebUI囉。
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →
  • 這是跑在本地端的,所以終端機記得不要關閉。
  • 若需要關閉Stable Diffusion WebUI,在終端機Ctrl+C即可。

跑一張圖約41秒

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

  • Stable Diffusion checkpoint: 1.5
  • Positive Prompt: Road, big white cottage, lake. Flower cottage switzerland
  • Negative Prompt: blurry, bad anatomy, extra limbs, poorly drawn face, poorly drawn hands, missing fingers
  • Sampling method: Euler a
  • Sampling steps: 20
  • Resolution: 512*512
  • Batch size: 1
  • CFG Scale: 7
  • Seed: 930288298

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →