当前位置:   article > 正文

【Stable Diffision】Macbook+外接SSD部署详细教程_commit hash: bef51aed032c0aaa5cfd80445bc4cf0d85b40

commit hash: bef51aed032c0aaa5cfd80445bc4cf0d85b408b5

一、必备环境安装

1.1 HomeBrew安装

brew install cmake protobuf rust python@3.10 git wget
  • 1

1.2 git clone SD项目

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
  • 1

当然,这一步可以选择是在本机或者是在移动硬盘上进行clone,我选择的是移动硬盘上

1.3 配置conda环境

安装好miniconda后,创建新的虚拟环境

conda create -n sdenv python=3.11
  • 1

注意,这里在选择python版本的时候最好要大于3.10

安装后

conda activate sdenv
  • 1
MacBook-Pro stable-diffusion-webui % python --version
Python 3.11.8
  • 1
  • 2

二、SD 安装

cd stable-diffusion-webui
./webui.sh
  • 1
  • 2

正常来说,等待安装结束即可。

三、其他

3.1 venv安装pytourch报错

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 37: invalid start byte
Traceback (most recent call last):
  File "/Volumes/T7/stable-diffusion-webui/launch.py", line 48, in <module>
    main()
  File "/Volumes/T7/stable-diffusion-webui/launch.py", line 39, in main
    prepare_environment()
  File "/Volumes/T7/stable-diffusion-webui/modules/launch_utils.py", line 380, in prepare_environment
    run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
  File "/Volumes/T7/stable-diffusion-webui/modules/launch_utils.py", line 115, in run
    raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't install torch.
Command: "/Volumes/T7/stable-diffusion-webui/venv/bin/python3" -m pip install torch==2.1.0 torchvision==0.16.0
Error code: 1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

直接更改为conda环境,webui.sh中搜索create,将199-224行激活虚拟环境的代码注释掉。
在这里插入图片描述

3.2 执行webui.sh过程中git报错

Commit hash: bef51aed032c0aaa5cfd80445bc4cf0d85b408b5
Cloning assets into /Volumes/T7/stable-diffusion-webui/repositories/stable-diffusion-webui-assets...
Cloning into '/Volumes/T7/stable-diffusion-webui/repositories/stable-diffusion-webui-assets'...
fatal: unable to access 'https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets.git/': Failure when receiving data from the peer
Traceback (most recent call last):
  File "/Volumes/T7/stable-diffusion-webui/launch.py", line 48, in <module>
    main()
  File "/Volumes/T7/stable-diffusion-webui/launch.py", line 39, in main
    prepare_environment()
  File "/Volumes/T7/stable-diffusion-webui/modules/launch_utils.py", line 410, in prepare_environment
    git_clone(assets_repo, repo_dir('stable-diffusion-webui-assets'), "assets", assets_commit_hash)
  File "/Volumes/T7/stable-diffusion-webui/modules/launch_utils.py", line 191, in git_clone
    run(f'"{git}" clone --config core.filemode=false "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}", live=True)
  File "/Volumes/T7/stable-diffusion-webui/modules/launch_utils.py", line 115, in run
    raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't clone assets.
Command: "git" clone --config core.filemode=false "https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets.git" "/Volumes/T7/stable-diffusion-webui/repositories/stable-diffusion-webui-assets"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

可以使用更加稳定的网络重新执行,或者将命令复制出来,重新执行。

cd repositories
git clone --config core.filemode=false "https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets.git"
  • 1
  • 2

当然,也可以使用一些github加速网站,下载后再将包放到对应文件夹下。

3.3 'openai/clip-vit-large-patch14’访问失败报错

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.
  • 1
  1. 手动访问https://huggingface.co/openai/clip-vit-large-patch14/tree/main
  2. 将这里的内容全部下载下来,例如下载到a目录中
    找到stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/modules/encoders/modules.py该文件,搜索openai/clip-vit-large-patch14,然后将它替换为你刚刚下载的文件夹a即可。

3.4 MPS framework doesn’t support float64

  File "/Volumes/T7/stable-diffusion-webui/modules/sd_disable_initialization.py", line 221, in load_state_dict
    original(module, state_dict, strict=strict)
  File "/Users/kimm/anaconda3/envs/sdenv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 2139, in load_state_dict
    load(self, state_dict)
  File "/Users/kimm/anaconda3/envs/sdenv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 2127, in load
    load(child, child_state_dict, child_prefix)
  File "/Users/kimm/anaconda3/envs/sdenv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 2127, in load
    load(child, child_state_dict, child_prefix)
  File "/Users/kimm/anaconda3/envs/sdenv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 2127, in load
    load(child, child_state_dict, child_prefix)
  [Previous line repeated 3 more times]
  File "/Users/kimm/anaconda3/envs/sdenv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 2121, in load
    module._load_from_state_dict(
  File "/Volumes/T7/stable-diffusion-webui/modules/sd_disable_initialization.py", line 226, in <lambda>
    conv2d_load_from_state_dict = self.replace(torch.nn.Conv2d, '_load_from_state_dict', lambda *args, **kwargs: load_from_state_dict(conv2d_load_from_state_dict, *args, **kwargs))
                                                                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/T7/stable-diffusion-webui/modules/sd_disable_initialization.py", line 191, in load_from_state_dict
    module._parameters[name] = torch.nn.parameter.Parameter(torch.zeros_like(param, device=device, dtype=dtype), requires_grad=param.requires_grad)
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kimm/anaconda3/envs/sdenv/lib/python3.11/site-packages/torch/_meta_registrations.py", line 4806, in zeros_like
    res = aten.empty_like.default(
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kimm/anaconda3/envs/sdenv/lib/python3.11/site-packages/torch/_ops.py", line 513, in __call__
    return self._op(*args, **(kwargs or {}))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kimm/anaconda3/envs/sdenv/lib/python3.11/site-packages/torch/_prims_common/wrappers.py", line 250, in _fn
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/kimm/anaconda3/envs/sdenv/lib/python3.11/site-packages/torch/_refs/__init__.py", line 4755, in empty_like
    return torch.empty_permuted(
           ^^^^^^^^^^^^^^^^^^^^^
TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32

只需要在执行webui.sh脚本的时候加上--disable-model-loading-ram-optimization参数接口。

./webui.sh --disable-model-loading-ram-optimization
  • 1

四、总结

至此,安装成功,大家就可以愉快的使用啦~当然后续也会将我配置好的包放上来,可以期待哦~

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/788092
推荐阅读
相关标签
  

闽ICP备14008679号