目录
先睹为快
开发环境
问题一,点“生成”按钮就退出程序
问题二、生成的图片是马赛克
第一步:解决环境问题
第二步:更新指定的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
问题二、生成的图片是马赛克
效果:
![](https://img-blog.csdnimg.cn/56a7bfe3132647c1b0a4cad96364420d.png)
第一步:解决环境问题
这个产生的原因很多,不过第一步,你应该先检查你的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.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)