Stable Diffusion WebUI 本地部署指南(Windows 11 + RTX 4060 Ti)

环境配置

  • 操作系统:Windows 11
  • 内存:32GB
  • GPU:NVIDIA RTX 4060 Ti (16GB)
  • Python 版本:3.10
  • CUDA 版本:12.1

一、准备工作

1. 安装必要工具

  • Git:用于克隆项目代码
  • Anaconda:用于创建和管理 Python 环境
  • NVIDIA 驱动:确保支持 CUDA 12.1+,建议安装最新版本

2. 创建 Python 环境

复制代码
# 创建名为sdenv的Python 3.10环境
conda create -n sdenv python=3.10 -y

# 激活环境
conda activate sdenv

二、下载 WebUI 项目

方法 1:使用 Git 克隆(推荐)

复制代码
# 克隆项目到当前目录
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

# 进入项目目录
cd stable-diffusion-webui

方法 2:手动下载 Release 包

  1. 访问 Releases · AUTOMATIC1111/stable-diffusion-webui · GitHub
  2. 下载最新版本的 Source code (zip)
  3. 解压到任意目录,建议路径不含中文和特殊字符

三、安装依赖与配置环境

1. 设置 pip 镜像源(加速下载)

复制代码
# 设置清华镜像为默认源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

# 添加阿里云镜像作为额外源
pip config set global.extra-index-url https://mirrors.aliyun.com/pypi/simple/

手动下载cuda依赖:

https://download.pytorch.org/whl/cu121/torch-2.1.2%2Bcu121-cp310-cp310-win_amd64.whl

进入虚拟环境后 pip install cu121-cp310-cp310-win_amd64.whl

复制代码
pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2

安装项目依赖

复制代码
# 安装requirements.txt中的所有依赖
pip install -r requirements.txt

四、启动 WebUI

使用 Python 命令启动

bash

复制代码
# 确保在虚拟环境中
python launch.py

五、访问 WebUI 界面

启动成功后,在浏览器中打开:

  • 本地访问:http://127.0.0.1:7860
  • 如需公网访问,添加--share参数启动:python launch.py --share

六、安装汉化包

方法:使用扩展安装

  1. 在 WebUI 中进入 Extensions 选项卡
  2. 点击 Install from URL
  3. 在输入框中填写:https://github.com/VinsonLaro/stable-diffusion-webui-chinese
  4. 点击 Install 按钮
  5. 安装完成后,在extensions-> install from url 里面填写 点击install之后 进入setting->user interface->User insterface, 勾选>
    Reload UI scripts when using Reload UI option
    (useful for developing: if you make changes to UI scripts code, it is applied when the UI is reloded.)
    然后 Localization (requires restart)",选择 Chinese-All-0313 ,点击应用设置 再重启UI

下载模型:

stable-diffusion-v1-5

Hugging Face 访问不了可以去魔搭社区

直接下载

v1-5-pruned-emaonly.safetensors

存放目录如下:

stable-diffusion-webui/

├── models/

│ └── Stable-diffusion/

│ └── v1-5-pruned-emaonly.safetensors # 模型文件

重启UI 就可以选中目标模型

问题 分词器下载失败

处理: 虚拟环境下找到 \Lib\site-packages\huggingface_hub\constants.py

修改国内镜像:

_HF_DEFAULT_ENDPOINT = "https://hf-mirror.com"

最后附加成品效果

相关推荐
爱分享的飘哥9 天前
第三十七章:文生图的炼金术:Stable Diffusion完整工作流深度解析
人工智能·pytorch·stable diffusion·文生图·ai绘画·代码实战·cfg
EndingCoder12 天前
Three.js + AI:结合 Stable Diffusion 生成纹理贴图
开发语言·前端·javascript·人工智能·stable diffusion·ecmascript·three.js
那年一路北12 天前
Deforum Stable Diffusion,轻松实现AI视频生成自由!
人工智能·stable diffusion·音视频
全宝12 天前
🎨【AI绘画实战】从零搭建Stable Diffusion环境,手把手教你生成超可爱Q版大头照!
人工智能·python·stable diffusion
sculida18 天前
秋叶sd-webui频繁出现生成后无反应的问题
stable diffusion
HORSE RUNNING WILD21 天前
【物理与机器学习】从非平衡热力学到扩散模型
人工智能·学习·机器学习·stable diffusion
取不好名字=23 天前
【ComfyUI学习笔记01】下载安装 | 运行第一个工作流 | 学习思路
笔记·学习·ai作画·stable diffusion
qq_398898931 个月前
【简单三步】Stable diffusion Webai本地部署无法加载模型并报openai/clip-vit-large-patch14错误的解决方法
stable diffusion
ai_xiaogui1 个月前
AIStarter用户与创作者模式详解:一键管理Stable Diffusion项目!
人工智能·stable diffusion·一键发布ai项目·熊哥aistarter教程·开发者必备aistarter
一禅(OneZen)1 个月前
「Windows/Mac OS」AIGC图片生成视频 ,webui + stable-diffusion环境部署教程
windows·stable diffusion