惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
N
Netflix TechBlog - Medium
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
I
InfoQ
V
V2EX
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
有赞技术团队
有赞技术团队
G
Google Developers Blog
L
LangChain Blog
博客园_首页
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
月光博客
月光博客
IT之家
IT之家
量子位
宝玉的分享
宝玉的分享
S
SegmentFault 最新的问题
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
雷峰网
雷峰网

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19)
如何在无 GPU 的 macOS 上运行 Stable Diffusion
微信公众号 · 2023-02-10 · via 陈少文的网站

Please enable Javascript to view the contents

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
1
brew install --cask anaconda
  • 配置 PATH
1
echo 'export PATH=/usr/local/anaconda3/bin:$PATH' >> ~/.zshrc
  • conda 初始化 Shell

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

  • 下载并进入项目目录
1
2
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd stable-diffusion-webui
  • 创建 Python 环境
1
conda create -n stabel python=3.10.6
  • 激活 Python 环境,并安装依赖
1
2
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]
1
export COMMANDLINE_ARGS="--lowvram --precision full --no-half --skip-torch-cuda-test --listen --port 7860"
  • 运行项目

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

如果启动时,出现类似 stderr: Running command git clone --filter=blob:none --quiet https://github.com/mlfoundations/open_clip.git 报错,可以编辑 launch.py 找到 def prepare_environment() 函数,修改 git+https://https://github.com/git+https://github.com/ 即可。

3. Text-to-Image 测试

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

4. 参考

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

微信公众号