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"

最后附加成品效果

相关推荐
code_pgf14 小时前
Stable-Diffusion模型中常见 Stable Diffusion Sampling 方法
人工智能·stable diffusion
水上冰石2 天前
v1-5-pruned-emaonly.safetensors 搭配mm_sd_v15_v2.ckpt 生成视频,具体操作步骤
stable diffusion·音视频·文生视频
日光明媚2 天前
TensorRT-LLM 中对 wan 加速流程与方法
人工智能·python·计算机视觉·stable diffusion·aigc
风落无尘2 天前
AIGC(Stable Diffusion 生态)常用知识与参数速查手册
人工智能·stable diffusion·aigc
水上冰石4 天前
stable-diffusion-webui怎么生成视频
人工智能·stable diffusion
切糕师学AI8 天前
深入解析 Stable Diffusion:原理、演进与应用实践
ai·ai作画·stable diffusion
xingyuzhisuan8 天前
哪里可以一键部署Stable Diffusion XL的GPU云环境?(2026实测指南)
运维·人工智能·stable diffusion·gpu算力
cskywit10 天前
【TMI2025】医学版 Stable Diffusion?3D MedDiffusion 如何生成高质量 3D 医学影像
人工智能·3d·stable diffusion
zenithdev110 天前
CompVisstable-diffusion
其他·stable diffusion
Soari10 天前
开启 AI 艺术创作之门:深度拆解 Stable Diffusion web UI,打造私有化文生图最强阵地
人工智能·ui·stable diffusion