MacOS13+系统运行Stable Diffusion出现的问题及解决方法汇总

MacOS13+系统运行Stable Diffusion出现的问题及解决方法汇总

    正在检查是否收录...
一言准备中...

 

目录

   先睹为快

  开发环境

问题一,点“生成”按钮就退出程序

问题二、生成的图片是马赛克

第一步:解决环境问题

第二步:更新指定的torch版本包

步骤一:更新指定的torch包:

步骤二:重新安装pytorch-nightly版本的包:

问题三:正确的启动webui.sh

  先睹为快

 

  开发环境

    硬件:基于Intel的CPU,AMD7970显卡,同样适用于所有AMD的GPU

    软件:python3.10,torch==1.12.1 torchvision==0.13.1

              或者:python3.11 torch==2.0.1 torchvision==0.15.2

  问题一,点“生成”按钮就退出程序

  报错如下:

loc("varianceEps"("(mpsFileLoc): /AppleInternal/Library/BuildRoots/a0876c02-1788-11ed-b9c4-96898e02b808/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShadersGraph/mpsgraph/MetalPerformanceShadersGraph/Core/Files/MPSGraphUtilities.mm":219:0)): error: input types 'tensor<1x77x1xf16>' and 'tensor<1xf32>' are not broadcast compatible LLVM ERROR: Failed to infer result type(s).

解决方法:修改webui-macos-env.sh

原来的内容:

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

修改为:

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

或者在启动webui.sh里添加参数:
 

>>./webui.sh --no-half

问题二、生成的图片是马赛克

效果:

第一步:解决环境问题

这个产生的原因很多,不过第一步,你应该先检查你的python环境,保证当前启动的python版本和pip版本是一致的。

检查方法:

>>python3 --version Python 3.11.4 >>pip3 --version pip 23.1.2 from /Users/heweiya/Library/Python/3.9/lib/python/site-packages/pip (python 3.9)

通过上面的方法可以看出,这两个版本是完全不匹配的,解决方法是把python的系统变量加到.zshrc配置文件当中,如下:

>>vi ~/.zshrc ## 添加:python 3.10和对应pip的目录地址到系统变量 export PYTHON_HOME=/usr/local/Cellar/python@3.10/3.10.12_1 export PIP_HOME=/usr/local/Cellar/python@3.10/3.10.12_1 export PATH="$PATH:$PYTHON_HOME/bin:$PIP_HOME/bin"

 请注意,不要全抄我写的内容,你要根据自己的环境设置PYTHON_HOME和PIP_HOME

 如果你本地有多个版本的python,可以卸载一个,比如我卸载3.11的方法

>>brew uninstall python@3.11 Uninstalling /usr/local/Cellar/python@3.11/3.11.4_1... (3,288 files, 61.9MB)

 然后再检查pip的版本,把pip的软链接到/usr/local/bin目录下去,就变成了系统默认的变量了。
 

>>which pip /usr/local/bin/pip >>sudo ln -sf /usr/local/bin/python3.10 /usr/local/bin/pip >>which pip /usr/local/bin/pip >>pip --version Python 3.10.12 

第二步:更新指定的torch版本包

第一步完成后,启动后会报下面的错误:
 

UserWarning: torch.cumsum supported by MPS on MacOS 13+, please upgrade (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/aten/src/ATen/native/mps/operations/UnaryOps.mm:264.) cumsum_needs_int_fix = not torch.Tensor([1,2]).to(torch.device("mps")).equal(torch.ShortTensor([1,1]).to(torch.device("mps")).cumsum(0)) /usr/local/lib/python3.10/site-packages/torchvision/transforms/functional_tensor.py:5: UserWarning: The torchvision.transforms.functional_tensor module is deprecated in 0.15 and will be **removed in 0.17**. Please don't rely on it. You probably just need to use APIs in torchvision.transforms.functional or in torchvision.transforms.v2.functional.

修改方法:


步骤一:更新指定的torch包:
 

>>pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu

步骤二:重新安装pytorch-nightly版本的包:


先安装conda

>>brew install --cask anaconda ==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/5bd9afe19051d38a3e67880beeebac028ff6de2b/Casks/anaconda.rb ########################################################################################################################################################################################### 100.0% ==> Downloading https://repo.anaconda.com/archive/Anaconda3-2023.03-1-MacOSX-x86_64.sh ########################################################################################################################################################################################### 100.0% ==> Installing Cask anaconda ==> Running installer script 'Anaconda3-2023.03-1-MacOSX-x86_64.sh' Password: PREFIX=/usr/local/anaconda3 Unpacking payload ... Installing base environment... Downloading and Extracting Packages Downloading and Extracting Packages Preparing transaction: ...working... done Executing transaction: ...working... Installed package of scikit-learn can be accelerated using scikit-learn-intelex. More details are available here: https://intel.github.io/scikit-learn-intelex For example: $ conda install scikit-learn-intelex $ python -m sklearnex my_application.py done installation finished. ==> Changing ownership of paths required by anaconda; your password may be necessary. ? anaconda was successfully installed!

安装软件包:
 

conda install pytorch torchvision torchaudio -c pytorch-nightly Collecting package metadata (current_repodata.json): done Solving environment: done ==> WARNING: A newer version of conda exists. <== current version: 23.3.1 latest version: 23.5.0 Please update conda by running $ conda update -n base -c defaults conda Or to minimize the number of packages updated during conda update use conda install conda=23.5.0 ## Package Plan ## environment location: /usr/local/anaconda3 added / updated specs: - pytorch - torchaudio - torchvision The following packages will be downloaded: package | build ---------------------------|----------------- blas-1.0 | mkl 6 KB ca-certificates-2023.05.30 | hecd8cb5_0 121 KB certifi-2023.5.7 | py310hecd8cb5_0 153 KB ffmpeg-4.2.2 | h97e5cf8_0 22.9 MB gnutls-3.6.15 | hed9c0bf_0 974 KB intel-openmp-2023.1.0 | ha357a0b_43547 635 KB lame-3.100 | h1de35cc_0 316 KB libidn2-2.3.4 | h6c40b1e_0 157 KB libopus-1.3.1 | h1de35cc_0 480 KB libtasn1-4.19.0 | h6c40b1e_0 67 KB libunistring-0.9.10 | h9ed2024_0 519 KB libvpx-1.7.0 | h378b8a2_0 1.3 MB llvmlite-0.40.0 | py310hfff2838_0 275 KB mkl-2023.1.0 | h59209a4_43558 181.0 MB mkl-service-2.4.0 | py310h6c40b1e_1 43 KB mkl_fft-1.3.6 | py310h3ea8b11_1 191 KB mkl_random-1.2.2 | py310h3ea8b11_1 270 KB nettle-3.7.3 | h230ac6f_1 380 KB numba-0.57.0 | py310h3ea8b11_0 4.3 MB numexpr-2.8.4 | py310h827a554_1 129 KB numpy-1.24.3 | py310h827a554_1 11 KB numpy-base-1.24.3 | py310ha186be2_1 5.9 MB openh264-2.1.1 | h8346a28_0 655 KB openssl-1.1.1u | hca72f7f_0 3.4 MB pytorch-2.1.0.dev20230709 | py3.10_0 81.9 MB pytorch-nightly scipy-1.10.1 | py310hdb2ea58_1 21.2 MB torchaudio-2.1.0.dev20230709| py310_cpu 5.4 MB pytorch-nightly torchvision-0.16.0.dev20230709| py310_cpu 6.6 MB pytorch-nightly x264-1!157.20191217 | h1de35cc_0 910 KB ------------------------------------------------------------ Total: 339.8 MB The following NEW packages will be INSTALLED: ffmpeg pkgs/main/osx-64::ffmpeg-4.2.2-h97e5cf8_0 gnutls pkgs/main/osx-64::gnutls-3.6.15-hed9c0bf_0 intel-openmp pkgs/main/osx-64::intel-openmp-2023.1.0-ha357a0b_43547 lame pkgs/main/osx-64::lame-3.100-h1de35cc_0 libidn2 pkgs/main/osx-64::libidn2-2.3.4-h6c40b1e_0 libopus pkgs/main/osx-64::libopus-1.3.1-h1de35cc_0 libtasn1 pkgs/main/osx-64::libtasn1-4.19.0-h6c40b1e_0 libunistring pkgs/main/osx-64::libunistring-0.9.10-h9ed2024_0 libvpx pkgs/main/osx-64::libvpx-1.7.0-h378b8a2_0 mkl pkgs/main/osx-64::mkl-2023.1.0-h59209a4_43558 mkl-service pkgs/main/osx-64::mkl-service-2.4.0-py310h6c40b1e_1 mkl_fft pkgs/main/osx-64::mkl_fft-1.3.6-py310h3ea8b11_1 mkl_random pkgs/main/osx-64::mkl_random-1.2.2-py310h3ea8b11_1 nettle pkgs/main/osx-64::nettle-3.7.3-h230ac6f_1 openh264 pkgs/main/osx-64::openh264-2.1.1-h8346a28_0 torchaudio pytorch-nightly/osx-64::torchaudio-2.1.0.dev20230709-py310_cpu torchvision pytorch-nightly/osx-64::torchvision-0.16.0.dev20230709-py310_cpu x264 pkgs/main/osx-64::x264-1!157.20191217-h1de35cc_0 The following packages will be UPDATED: ca-certificates 2023.01.10-hecd8cb5_0 --> 2023.05.30-hecd8cb5_0 certifi 2022.12.7-py310hecd8cb5_0 --> 2023.5.7-py310hecd8cb5_0 llvmlite 0.39.1-py310h8346a28_0 --> 0.40.0-py310hfff2838_0 numba 0.56.4-py310h3ea8b11_0 --> 0.57.0-py310h3ea8b11_0 numexpr 2.8.4-py310he50c29a_0 --> 2.8.4-py310h827a554_1 numpy 1.23.5-py310he50c29a_0 --> 1.24.3-py310h827a554_1 numpy-base 1.23.5-py310h992e150_0 --> 1.24.3-py310ha186be2_1 openssl 1.1.1t-hca72f7f_0 --> 1.1.1u-hca72f7f_0 pytorch pkgs/main::pytorch-1.12.1-cpu_py310h6~ --> pytorch-nightly::pytorch-2.1.0.dev20230709-py3.10_0 scipy 1.10.0-py310ha516a68_1 --> 1.10.1-py310hdb2ea58_1 The following packages will be DOWNGRADED: blas 1.0-openblas --> 1.0-mkl Proceed ([y]/n)? y Downloading and Extracting Packages Preparing transaction: done Verifying transaction: | WARNING conda.core.path_actions:verify(1093): Unable to create environments file. Path not writable. environment location: /Users/heweiya/.conda/environments.txt done Executing transaction: done 

问题三:正确的启动webui.sh

方法:
 

heweiya@heweiyadeMac-Pro stable-diffusion-webui % source venv/bin/activate (venv) heweiya@heweiyadeMac-Pro stable-diffusion-webui % ./webui-macos-env.sh (venv) heweiya@heweiyadeMac-Pro stable-diffusion-webui % ./webui-user.sh (venv) heweiya@heweiyadeMac-Pro stable-diffusion-webui % ./webui.sh 

成功!

赠图:

正向提示词:
Original Characters, Natural Volumetric Lighting And Best Shadows, Deep Depth Of Field, Sharp Focus, Portrait Of Stunningly Beautiful Petite Girl, Soft Delicate Beautiful Attractive Face With Alluring Brown Eyes, Lovely Medium Small Breasts, Sharp Eyeliner, Seductive Smiling, Closed Mouth, Windswept Disheveled Brown Hair, Thick Layered Medium Hairstyles, Blush Eyeshadow With Thick Eyelashes, Parted Lips, Oversized Straw Sun Hat, Single Ribbon Bow, White Rustic One-piece Dress Long, (Flutter In The Wind:1.1), (Ripe Yellow Rye Field Under Beautiful Summer Sunset Sky With Clouds:1.2), (Highest Quality, Amazing Details:1.4), Masterpiece, Bloom, Picturesque, Vivid Watercolor Paintings,White gloves
反向指示词:

(worst quality, low quality, loli, child, infant, baby:1.4), lowres, blurry, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, (signature, watermark, username,letter, letterboxed, copyright name, copyright, chinese text, artist name, name tag, company name, name tag, text, error:1.5)  

codepythonpytorchwebwebuimaccpuintelactionmacosnumpydiffusiongitrapnistappmediumword马赛克urlmbafixgithub2024applejsonivanativefluttercreateeloerphivescript提示词gputrawapi
  • 本文作者:WAP站长网
  • 本文链接: https://wapzz.net/post-2297.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
本站部分内容来源于网络转载,仅供学习交流使用。如涉及版权问题,请及时联系我们,我们将第一时间处理。
文章很赞!支持一下吧 还没有人为TA充电
为TA充电
还没有人为TA充电
0
  • 支付宝打赏
    支付宝扫一扫
  • 微信打赏
    微信扫一扫
感谢支持
文章很赞!支持一下吧
关于作者
2.7W+
9
1
2
WAP站长官方

Google Bard vs ChatGPT:哪一个更适合创造富有创造性的文学作品?

上一篇

【Stable Diffusion安装】支持python3.11 window版

下一篇
  • 复制图片
按住ctrl可打开默认菜单