【本地化部署Stable Diffusion WebUI(MACOS安装)】

03-15 1198阅读 0评论

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

【本地化部署Stable Diffusion WebUI(MACOS安装)】,【本地化部署Stable Diffusion WebUI(MACOS安装)】,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,访问,人工智能,安装,第1张
(图片来源网络,侵删)

文章目录

  • 前言
  • 一、Stable Diffusion WebUI适配三类芯片
  • 二、安装
    • 1.安装git、conda等
    • 2.选定目录及下载Github远程仓库文件
    • 3.创建conda虚拟环境
    • 4.安装依赖
      • pip速度慢需添加国内pip源
      • 5.运行
      • 6.问题处理
        • 缺openai模块等
            • 手动git clone
            • 类似的v1-5-pruned-emaonly.safetensors模型获取失败
            • RuntimeError: "LayerNormKernelImpl" not implemented for 'Half'等
            • 正常运行sdw的的话会自动访问http://127.0.0.1:7860/
              • 命令行显示类似如下:
              • 浏览器显示如下:
              • 绘图时报错
                • 很显然是绘图时需要访问huggingface.co下载模块
                  • 修改webu.sh
                  • 绘图时会有如下显示:
                  • 绘图结束显示
                  • 总结

                    前言

                    随着人工智能的不断发展,AI绘图热兴起,我也想加入到AI绘图大潮中。


                    一、Stable Diffusion WebUI适配三类芯片

                    此模型支持三类GPU芯片

                    1. NVidia (recommended)
                    2. AMD GPUs.
                    3. Intel CPUs, Intel GPUs (bothintegrated and discrete) (我的mac属于此情况)

                    二、安装

                    说明:期间需要访问外网,自行实现巧妙上网

                    1.安装git、conda等

                    brew install cmake protobuf rust python@3.10 git wget miniconda
                    

                    2.选定目录及下载Github远程仓库文件

                    mkdir SDW
                    cd SDW
                    git clone git@github.com:openvinotoolkit/stable-diffusion-webui.git
                    

                    3.创建conda虚拟环境

                    创建虚拟环境

                    conda env create -p /Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/automatic -f /Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/environment-wsl2.yaml
                    

                    最后创建完成后显示如下:

                    # To activate this environment, use     
                    #                                       
                    #     $ conda activate /Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/automatic   
                    #                                       
                    # To deactivate an active environment, use                                             
                    #                                       
                    #     $ conda deactivate
                    

                    激活环境

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】,【本地化部署Stable Diffusion WebUI(MACOS安装)】,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,访问,人工智能,安装,第2张
                    (图片来源网络,侵删)
                    conda activate /Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/automatic
                    

                    4.安装依赖

                    cd stable-diffusion-webui
                    pip install -r requirements.txt
                    

                    pip速度慢需添加国内pip源

                    cd ~
                    mkdir .pip
                    cd .pip
                    touch pip.conf
                    在pip.conf文件中,添加以下内容:
                    [global]
                    index-url = https://pypi.doubanio.com/simple/
                    trusted-host = pypi.doubanio.com
                    

                    5.运行

                    还有未安装的依赖在此步骤执行中会一次安装,当然有报错需要一次解决。

                    英特尔CPU+GPU的场景执行前环境要生效如下内容:

                    export PYTORCH_TRACING_MODE=TORCHFX
                    export COMMANDLINE_ARGS="--skip-torch-cuda-test --precision full --no-half" 
                    ./webui.sh
                    

                    6.问题处理

                    运行./webui.sh会有很多报错

                    缺openai模块等

                    OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'openai/clip-vit-large-patch14' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer.
                    
                    手动git clone

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】

                    可直接git clone

                    可以指定git代理实现

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】,【本地化部署Stable Diffusion WebUI(MACOS安装)】,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,访问,人工智能,安装,第4张
                    (图片来源网络,侵删)
                    #指定git代理
                    git config --global https.proxy socks5://127.0.0.1:1088
                    或
                    git config --global https.proxy https://127.0.0.1:1088
                    #取消git代理
                    git config --global --unset https.proxy
                    

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】

                    例如:
                    git clone https://huggingface.co/openai/clip-vit-large-patch14
                    或
                    git clone git@hf.co:openai/clip-vit-large-patch14
                    
                    类似的v1-5-pruned-emaonly.safetensors模型获取失败

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】

                    https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
                    

                    此文件较大有4G多,建议通过从源网站下载到云盘,再从云盘下载到本地,然后让入目标文件夹如:stable-diffusion-uebul/models/Stable-diffusion/

                    RuntimeError: “LayerNormKernelImpl” not implemented for 'Half’等

                    RuntimeError: "LayerNormKernelImpl" not implemented for 'Half'
                    /Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/functional.py", line 2515, in layer_norm
                    RuntimeError: "addmm_impl_cpu_" not implemented for 'Half'
                    /Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/modules/linear.py", line 114, in forward
                    

                    那么执行时添加如下参数:

                    ./webui.sh --precision full --no-half 
                    

                    正常运行sdw的的话会自动访问http://127.0.0.1:7860/

                    命令行显示类似如下:

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】

                    浏览器显示如下:

                    注意选择支持intel GPU的script,OpenVINO™ Acceleration Script

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】

                    绘图时报错

                    类似如下报错

                    报错显示如下:

                    OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like CompVis/stable-diffusion-safety-checker is not the path to a directory containing a file named config.json. Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.
                    

                    以及

                       Traceback (most recent call last):
                          File "/Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/urllib3/connection.py", line 198, in _new_conn
                            sock = connection.create_connection(
                          File "/Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
                            raise err
                          File "/Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/urllib3/util/connection.py", line 73, in create_connection
                            sock.connect(sa)
                        TimeoutError: timed out
                        The above exception was the direct cause of the following exception:
                        Traceback (most recent call last):
                          File "/Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 793, in urlopen
                            response = self._make_request(
                          File "/Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 491, in _make_request
                            raise new_e
                          File "/Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 467, in _make_request
                            self._validate_conn(conn)
                          File "/Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1099, in _validate_conn
                            conn.connect()
                          File "/Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/urllib3/connection.py", line 616, in connect
                            self.sock = sock = self._new_conn()
                          File "/Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/urllib3/connection.py", line 207, in _new_conn
                            raise ConnectTimeoutError(
                        urllib3.exceptions.ConnectTimeoutError: (, 'Connection to huggingface.co timed out. (connect timeout=10)')
                        The above exception was the direct cause of the following exception:
                        Traceback (most recent call last):
                          File "/Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/requests/adapters.py", line 486, in send
                            resp = conn.urlopen(
                          File "/Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 847, in urlopen
                            retries = retries.increment(
                          File "/Users/zhaoyao/Downloads/SDW/stable-diffusion-webui/venv/lib/python3.10/site-packages/urllib3/util/retry.py", line 515, in increment
                            raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
                        urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /CompVis/stable-diffusion-safety-checker/resolve/main/config.json (Caused by ConnectTimeoutError(, 'Connection to huggingface.co timed out. (connect timeout=10)'))
                    

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】

                    很显然是绘图时需要访问huggingface.co下载模块

                    考虑直接添加代理的方式,因为不可能每次画图每次需要下载模块的时候每次手动下载

                    修改webu.sh

                    在此文件后追加代理

                    proxy='socks5://127.0.0.1:1088'
                    export http_proxy=$proxy
                    export https_proxy=$proxy
                    export no_proxy="localhost, *.local, 127.0.0.1, ::1, 192.168.*.*, 10.*.*.*, 172.16-31.*.*, *.baidu.com*, *.bilibili.com*, *.cn*, *.com.cn*, *.csdn.net*, *.51cto*, *tencent*, *qq.com*, *weixin*, *ali*, *dingding*, *huawei*, *xunlei*, *tonghuashun*, *dongfangcaifu*, *i4tool*, *163.com*, *doubanio.com*, *douban*, *youku*"
                    

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】

                    绘图时会有如下显示:

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】

                    绘图结束显示

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】

                    【本地化部署Stable Diffusion WebUI(MACOS安装)】


                    总结

                    参考于https://github.com/openvinotoolkit/stable-diffusion-webui

                    https://openai.wiki/stable-diffusion-webui-localization.html。


免责声明
本网站所收集的部分公开资料来源于AI生成和互联网,转载的目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

发表评论

快捷回复: 表情:
评论列表 (暂无评论,1198人围观)

还没有评论,来说两句吧...

目录[+]