【stable-diffusion】4090显卡下dreambooth、lora、sd模型微调的GUI环境安装(cuda驱动、pytorch、xformer)

相关博文

  1. stable-diffusion-webui的基础功能手动安装,了解代码结构、依赖、模型出处

安装成功结果

主要参考

  • cuda11.7下载-https://developer.nvidia.com/cuda-toolkit-archive
  • cudnn8.6 for 11.x : https://developer.nvidia.com/rdp/cudnn-archive
  • dreambooth\lora 训练环境:
    • 最原始的命令端 https://github.com/kohya-ss/sd-scripts
    • GUI端口 https://github.com/bmaltais/kohya_ss
  • 环境安装参考:win11 系统 GPU版本pytorch、CUDA、anaconda 、pycharm详细安装教程

一、显卡驱动相关

驱动版本自带cuda 12.0 与pytorch不兼容

驱动要安装官网4090自带的:528.02 cuda12.0 (运维安装跳过)

pytorch 需要cuda12.0以下

自定义安装

取消安装驱动


明确安装位置,好添加到系统路径

安装成功和失败的

cudnn 下载与安装

  • https://developer.nvidia.com/rdp/cudnn-archive

改名放到cuda安装目录下,并添加到环境变量

根目录

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\

结果

最终环境变量

肯定有些冗余

二、安装 python3.10 + pytorch

下载安装miniconda (python 3.10.9)

官网直接选择最新版本 : https://docs.conda.io/en/latest/miniconda.html

添加到系统环境

计算机—》属性—》高级系统设置—-》环境变量—》系统变量—》path

根据自己位置改

D:\miniconda310\Scripts
D:\miniconda310

安装pytorch

  • https://pytorch.org/

配置pip的国内源并升级

pip config set global.index-url  https://mirror.baidu.com/pypi/simple
pip config set global.trusted-host mirror.baidu.com
python -m pip install --upgrade pip

查找对应的pytorch

lora dreambooth推荐的环境:https://github.com/bmaltais/kohya_ss/blob/master/setup.bat

pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117

需要15分钟左右时间

三、其他python依赖包

安装requirements

–upgrade使用最新版本的pip
进入 kohya_ss-master的位置

pip install --upgrade -r requirements.txt

ERROR: Cannot find command ‘git’ – do you have ‘git’ installed and in your PATH?

https://gitforwindows.org/

conda install git

git不是内部外部命令,添加到系统环境

  • https://www.cnblogs.com/ldq678/p/13287924.html
    找到自己的路径

安装过程截图

开始安装

成功

安装 xformer

  • https://github.com/facebookresearch/xformers
conda install xformers -c xformers
or
pip install -U xformers

本项目特定环境安装(不然训练报错,必须装

copy /y .\bitsandbytes_windows\*.dll D:\miniconda310\Lib\site-packages\bitsandbytes\
copy /y .\bitsandbytes_windows\cextension.py D:\miniconda310\Lib\site-packages\bitsandbytes\cextension.py
copy /y .\bitsandbytes_windows\main.py D:\miniconda310\Lib\site-packages\bitsandbytes\cuda_setup\main.py

accelerate config  

配置

erro 训练时报错 No model named ‘triton’

链接:https://pan.baidu.com/s/1shX-cU-R-0_gKhiTM0VXSw
提取码:6666

pip install triton-2.0.0-cp310-cp310-win_amd64.whl

四、启动训练界面

python D:\kohya_ss-master\kohya_gui.py

附录

本项目cudnn8.6 特殊安装

4090使用cudnn8.6能加速50%

下载后解压,放入文件夹

将cudnn保存到虚拟环境中

python D:\kohya_ss-master\tools\cudann_1.8_install.py

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2023年6月12日
下一篇 2023年6月12日

相关推荐