stable-diffusion安装

stable-diffusion

  • 安装python

  • 安装git

  • 安装cude

  • 拉去项目

  • 报错

安装

因为stable-diffusion是基于python写的,所以需要安装python解释器。

Python解释器

  1. 版本

    因为教程是之前写的,所以教程上是3.6的,推荐下载3.10.6的

    如果不会在配置环境变量则记得把自动配置环境变量的这一选项打勾

  2. 下载

    官网

    https://www.python.org

    • 鼠标放到Downloads上选择跟自己计算机系统所版本然后点击

    • 然后找到自己所想下载的版本以3.6.4为例

      • installer结尾的是exe文件一个执行程序

        zip结尾的是下载好一个压缩包

    • 然后打开

    • 然后下一步

    • 选择路径

    • 然后喝杯茶等待。。。。安装完成

    这是你之前没有安装过python的情况下,如果安装过python,建议你是使用conda。
    • 验证安装是否成功

      win + r

      image-20230709190444346

    回车

    image-20230709203630889

    执行 pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

    image-20230709203747108

    安装git

    用来克隆github的项目,比如本作中的stable diffusion webui 前往git官网https://git-scm.com/download/win

    image-20230709191842466

    一路下一步就行了

    • 验证

      image-20230709192006551

    安装cuda

    cuda是NVIDIA显卡用来跑算法的依赖程序所以我们需要它。

    打开NVIDIA cuda官网 https://developer.nvidia.com/cuda-toolkit-archive

    打不开的可以魔法上网

    你会发现有很多版本,下载那个版本呢?

    image-20230709192924500

    回到用来验证git和python的界面,输入nvidia-smi,查看你的cuda版本

    image-20230709193108118

    我的是11.7的版本,我就下载11.7.0的链接

    image-20230709193204589

    image-20230709193237063

    image-20230709193316332

    image-20230709193415051

    下载完后安装,这个软件2个G,可以安装在c盘以外的地方。比如D盘。

    好了,完成这步,电脑的基础环境设置终于完事了。

    下面开始正式折腾stable diffusion了。

    安装stable diffusion

    1. 拉去代码

      找到你想把stable diffusion放到的位置

      比如我想放到E盘

      image-20230709193712012

      image-20230709193732316

      image-20230709193750384

      image-20230709193811274

      输入git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

      然后显示这个

      image-20230709193903316

      等待拉去完即可。

      如果觉得慢的

      可以进入https://github.com/AUTOMATIC1111/stable-diffusion-webui这个页面

      如果进不去可以魔法上网,因为这个国外的网站

      image-20230709194042141

      image-20230709194106857

      把下载好的压缩包解压到自己想放的位置即可

      image-20230709194249311

      基本上长这个样子

      image-20230709194622567

      报错的几率很大

    报错

    installing gfpgan

    一直处于这种状态的

    那么你就可以把项目这个项目拉下来,手动去安装这些依赖

    image-20230709195456645

    就是报这个error

    image-20230709195825835

    E: stable-diffusion-webui-master stable-diffusion-webui-mastervenrScripts python. exe -m pip install --upgrade pip是这一条

    image-20230709200321466

    网址https://github.com/TencentARC/GFPGAN/

    跟下载stable diffusion一样,去这个网址,点code,点ZIP即可

    把下载好安装包放到项目的根目录下

    image-20230709202227795

    image-20230709202252923

    把解压好的文件夹放到项目的根目录

    image-20230709202415649

    然后输入

    image-20230709202448568

    image-20230709202612476

    image-20230709202636425

    回车

    就进入到了

    image-20230709202650302

    当你执行过一次 webbui-user的时候会自动创建一个venv文件。我们现在是进入到stable-diffusion给我创建的虚拟环境中

    可以执行pip -V

    查看当前的pip属于那个python

    image-20230709203008507

    我要 cd 到

    image-20230709203125783

    pip 临时换源

    清华源: -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
    阿里源: -i https://mirrors.aliyun.com/pypi/simple
    

    pip永久换源

    升级 pip 到最新的版本 (>=10.0.0) 后进行配置:
    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
    

    现在我们使用临时的换源

    先进入到GFPGAN-master

    image-20230709203921833

    然后执行pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple

    image-20230709204152951

    在执行python setup.py develop

    image-20230709204339508

    能魔法上网就开启魔法上网

    的执行webui-user.bat

    成功率可能会搞一点

    Couldn't clone Stable Diffusion

    image-20230709204959525

    image-20230709205113881

    https://github.com/Stability-AI/stablediffusion.git
    还是跟gfpgan一样

    pip 下载的时候记得把魔法上网关了

    这个只需要执行pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple这个即可

    image-20230709211445426

    image-20230709211533453

    好了结束

    sd的一写依赖包(1)输入git clone https://github.com/Stability-AI/stablediffusion.git

    (2)输入git clone https://github.com/CompVis/taming-transformers.git

    (3)输入git clone https://github.com/crowsonkb/k-diffusion.git

    (4)输入git clone https://github.com/sczhou/CodeFormer.git

    (5)输入git clone https://github.com/salesforce/BLIP.git

    这是一些依赖包

posted @ 2023-07-09 21:23  可否  阅读(380)  评论(0)    收藏  举报