由于“torch_directml”而在 macOS 上安装 Stable-Diffusion 时出现问题

问题描述 投票:0回答:1

我一直在尝试在 MacBook Pro 上安装 Stable-Diffusion,但遇到了与 torch_directml 相关的错误。据我了解,torch_directml 特定于 Windows 和 DirectX 环境。您能否告知如何在 macOS 上进行安装?

以下是我的MacBook Pro的规格供参考:

  • 型号:MacBook Pro 16 英寸,2019 年
  • 处理器:2.3 GHz 8 核 Intel Core i9
  • 显卡:AMD Radeon Pro 5500M 4 GB 和 Intel UHD Graphics 630 1536 MB
  • 内存:16 GB 2667 MHz DDR4
  • macOS:索诺玛 14.0

这是我收到的错误消息:

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
fatal: No names found, cannot describe anything.
Python 3.10.9 (main, Mar  1 2023, 12:33:47) [Clang 14.0.6 ]
Version: 1.6.0
Commit hash: 44f1acaae3ef6868a4767eb3c89b8265664aada5
Launching Web UI with arguments: --skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate
2023-10-05 19:42:39.837650: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
No module 'xformers'. Proceeding without it.
Traceback (most recent call last):
  File "/Users/stable-diffusion-webui/launch.py", line 48, in <module>
    main()
  File "/Users/stable-diffusion-webui/launch.py", line 44, in main
    start()
  File "/Users/stable-diffusion-webui/modules/launch_utils.py", line 679, in start
    import webui
  File "/Users/stable-diffusion-webui/webui.py", line 13, in <module>
    initialize.imports()
  File "/Users/stable-diffusion-webui/modules/initialize.py", line 34, in imports
    shared_init.initialize()
  File "/Users/stable-diffusion-webui/modules/shared_init.py", line 25, in initialize
    dml.initialize()
  File "/Users/stable-diffusion-webui/modules/dml/__init__.py", line 40, in initialize
    from modules.dml.backend import DirectML # pylint: disable=ungrouped-imports
  File "/Users/stable-diffusion-webui/modules/dml/backend.py", line 4, in <module>
    import torch_directml # pylint: disable=import-error
ModuleNotFoundError: No module named 'torch_directml'

任何指导或解决方法将不胜感激。谢谢!

python macos torch stable-diffusion
1个回答
0
投票

经过多次尝试。我终于可以安装了。

安装 stable-diffusion-webui 时出现“torch_directml”错误的解决方案。

  1. 创建并激活虚拟环境:

    python3 -m venv stable_diffusion_env

    source stable_diffusion_env/bin/activate

  2. 克隆存储库:

    git clone https://github.com/openvinotoolkit/stable-diffusion-webui.git

  3. 导航到存储库:

    cd stable-diffusion-webui

  4. 安装特定 Torch 和 Torchvision 版本:

    pip install torch==2.0.1 torchvision==0.15.2

  5. 升级点:

    pip install --upgrade pip

  6. 自定义'webui-user.sh'

    if [[ -x "$(command -v python3.10)" ]]

    then

       python_cmd="python3.10"

    fi

    export install_dir="$HOME"

    export COMMANDLINE_ARGS="--skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate"

    export TORCH_COMMAND="pip install torch==2.0.1 torchvision==0.15.2"

    export PYTORCH_ENABLE_MPS_FALLBACK=1

  7. 运行webui.sh脚本。

    ./webui.sh

© www.soinside.com 2019 - 2024. All rights reserved.