如何在无 GPU 的 macOS 上运行 Stable Diffusion

商务办公
Prompt 有很多的撰写技巧、句式、修饰词;Stable Diffusion 也有很多参数可以调整。但本篇主要描述的是在无 GPU 情况下,在 macOS 下运行 Stable Diffusion,因此在此仅输入 bird ,进行测试。

​1. 运行 Stable Diffusion 推荐配置

  • 内存: 不低于 16 GB DDR4 或 DDR5
  • 存储: 不低于 10 GB 可用空间
  • GPU: 不低于 6 GB 显存 N 卡

如果硬件达不到要求,也可以使用各种优化 fork 兼容更低配置的硬件,但生成时间会增长。

当前的开发主机配置为:

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

由于没有 GPU,生成图片时,需要多等待一会儿。

2. macOS 上运行 Stable Diffusion

  • 安装 anaconda
brew install --cask anaconda
  • 配置 PATH
echo 'export PATH=/usr/local/anaconda3/bin:$PATH' >> ~/.zshrc
  • conda 初始化 Shell
conda init zsh

这里需要关闭窗口,重新登录 Terminal。

  • 下载并进入项目目录
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd stable-diffusion-webui
  • 创建 Python 环境
conda create -n stabel python=3.10.6
  • 激活 Python 环境,并安装依赖
conda activate stabel 
pip3 install -r requirements_versions.txt
  • 下载模型

前往 https://huggingface.co/CompVis/stable-diffusion-v-1-4-original 下载 sd-v1-4.ckpt 或者 sd-v1-4-full-ema.ckpt 文件,放置到 models/Stable-diffusion ⽬录下。huggingface 上也有很多其他模型可以下载使用,也能在线体验。比如 https://huggingface.co/spaces/IDEA-CCNL/Taiyi-Stable-Diffusion-Chinese 。

  • 修改运行参数,跳过 GPU 检测,参考[1]
export COMMANDLINE_ARGS="--lowvram --precision full --no-half --skip-torch-cuda-test"
  • 运行项目
python launch.py

在本地访问 http://127.0.0.1:7860 即可打开 UI。

3. Text-to-Image 测试

Prompt 有很多的撰写技巧、句式、修饰词;Stable Diffusion 也有很多参数可以调整。但本篇主要描述的是在无 GPU 情况下,在 macOS 下运行 Stable Diffusion,因此在此仅输入 bird ,进行测试。生成的图片如下图:

图片

4. 参考

  1. https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/1742
责任编辑:武晓燕 来源: 陈少文
相关推荐

2023-07-14 13:34:34

StableDiffusion模型

2017-04-04 20:31:05

AWS GPUJupyter not深度学习

2019-07-23 09:10:41

MacOSKibana开源

2019-07-22 08:05:21

MacOSElasticsear

2019-08-07 18:52:40

GPU数据科学CPU

2023-05-24 08:52:12

2017-09-18 10:05:15

WindowsLinux容器

2023-01-10 16:08:04

人工智能扩散模型

2017-02-16 10:15:43

Windows7docker变量

2021-02-25 08:00:00

WindowsWindows 10开发

2021-08-09 09:00:00

Kubernetes云计算架构

2022-09-13 08:40:24

AndroidLinux

2019-09-29 09:40:20

LinuxWindowsMacOS

2021-05-09 21:35:25

Java机器代码

2019-05-09 09:00:00

WindowsKafka

2014-03-31 09:45:33

Ubuntu LinuUbuntu 13.1

2009-04-16 09:59:16

Google App PHPJava

2023-05-26 15:53:48

MidjourneyAI图像

2014-10-11 11:30:43

CentOSDocker

2016-08-02 10:34:17

LinuxWindows双启动
点赞
收藏

51CTO技术栈公众号