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"

最后附加成品效果

相关推荐
CoovallyAIHub4 天前
突破异常数据瓶颈!AnomalyAny:一句话+一张图,零样本生成任意异常图像
计算机视觉·stable diffusion
写代码的小阿帆5 天前
Fractal Generative Models论文阅读笔记与代码分析
论文阅读·stable diffusion·transformer
春末的南方城市6 天前
港科大&快手提出统一上下文视频编辑 UNIC,各种视频编辑任务一网打尽,还可进行多项任务组合!
人工智能·计算机视觉·stable diffusion·aigc·transformer
多恩Stone10 天前
【Stable Diffusion 1.5 】在 Unet 中每个 Cross Attention 块中的张量变化过程
stable diffusion
今夕节度使10 天前
ARM架构推理Stable Diffusiond
stable diffusion
远瞻。14 天前
【论文精读】2024 ECCV--MGLD-VSR现实世界视频超分辨率(RealWorld VSR)
人工智能·算法·stable diffusion·音视频·超分辨率重建
远瞻。15 天前
【论文精读】2024 CVPR--Upscale-A-Video现实世界视频超分辨率(RealWorld VSR)
论文阅读·人工智能·算法·stable diffusion·音视频·超分辨率重建
乱世刀疤15 天前
AI绘画:手把手带你Stable Diffusion从入门到精通(系列教程)
人工智能·ai作画·stable diffusion
layneyao17 天前
从0到1搭建AI绘画模型:Stable Diffusion微调全流程避坑指南
ai作画·stable diffusion