背景:自己的電腦是macbookpro m2,之前裝很多軟件都遇到各種問題,不出意外,裝這個stable-diffusion一樣遇到各種問題,現(xiàn)在總結(jié)一下安裝過程中遇到的問題。
報錯一:
Launching Web UI with arguments: --skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate
no module 'xformers'. Processing without...
No SDP backend available, likely because you are running in pytorch versions < 2.0. In fact, you are using PyTorch 1.12.1. You might want to consider upgrading.
no module 'xformers'. Processing without...
No module 'xformers'. Proceeding without it.
Style database not found: /Users/wuzhanxi/stable-diffusion-webui/styles.csv
Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled
==============================================================================
You are running torch 1.12.1.
The program is tested to work with torch 2.0.0.
To reinstall the desired version, run with commandline flag --reinstall-torch.
Beware that this will cause a lot of large files to be downloaded, as well as
there are reports of issues with training tab on the latest version.
Use --skip-version-check commandline argument to disable this check.
==============================================================================
Downloading: "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors" to /Users/wuzhanxi/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors
WARNING:modules.mac_specific:MPS garbage collection failed
Traceback (most recent call last):
File "/Users/wuzhanxi/stable-diffusion-webui/modules/mac_specific.py", line 38, in torch_mps_gc
from torch.mps import empty_cache
ModuleNotFoundError: No module named 'torch.mps'
原因:torch 的版本不對
解決方案:在安裝目錄stable-diffusion-webui 下,編輯webui-macos-env.sh 文件
我的原來的配置文件如下;
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==1.12.1 torchvision==0.13.1"
export K_DIFFUSION_REPO="https://github.com/brkirch/k-diffusion.git"
export K_DIFFUSION_COMMIT_HASH="51c9778f269cedb55a4d88c79c0246d35bdadb71"
export PYTORCH_ENABLE_MPS_FALLBACK=1
修改好的配置文件如下;1.在COMMANDLINE_ARGS 參數(shù)的后面添加了–reinstall-torch
2.export TORCH_COMMAND=“pip install torch2.0.1 torchvision0.15.2”,將torch的版本修改成2.0的
export install_dir="$HOME"
export COMMANDLINE_ARGS="--skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate --reinstall-torch"
export TORCH_COMMAND="pip install torch==2.0.1 torchvision==0.15.2"
#export TORCH_COMMAND="pip install torch==1.12.1 torchvision==0.13.1"
export K_DIFFUSION_REPO="https://github.com/brkirch/k-diffusion.git"
export K_DIFFUSION_COMMIT_HASH="51c9778f269cedb55a4d88c79c0246d35bdadb71"
export PYTORCH_ENABLE_MPS_FALLBACK=1
報錯二:
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
Startup time: 4.4s (prepare environment: 0.9s, import torch: 1.2s, import gradio: 0.4s, setup paths: 0.5s, other imports: 0.4s, load scripts: 0.3s, create ui: 0.2s, gradio launch: 0.3s).
Creating model from config: /Users/wuzhanxi/stable-diffusion-webui/configs/v1-inference.yaml
creating model quickly: OSError
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 973, in _bootstrap
self._bootstrap_inner()
File "/opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/Users/wuzhanxi/stable-diffusion-webui/modules/initialize.py", line 147, in load_model
shared.sd_model # noqa: B018
File "/Users/wuzhanxi/stable-diffusion-webui/modules/shared_items.py", line 128, in sd_model
return modules.sd_models.model_data.get_sd_model()
File "/Users/wuzhanxi/stable-diffusion-webui/modules/sd_models.py", line 531, in get_sd_model
load_model()
File "/Users/wuzhanxi/stable-diffusion-webui/modules/sd_models.py", line 634, in load_model
sd_model = instantiate_from_config(sd_config.model)
File "/Users/wuzhanxi/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py", line 89, in instantiate_from_config
return get_obj_from_str(config["target"])(**config.get("params", dict()))
File "/Users/wuzhanxi/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 563, in __init__
self.instantiate_cond_stage(cond_stage_config)
File "/Users/wuzhanxi/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 630, in instantiate_cond_stage
model = instantiate_from_config(config)
File "/Users/wuzhanxi/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py", line 89, in instantiate_from_config
return get_obj_from_str(config["target"])(**config.get("params", dict()))
File "/Users/wuzhanxi/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/modules/encoders/modules.py", line 104, in __init__
self.tokenizer = CLIPTokenizer.from_pretrained(version)
File "/opt/homebrew/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1809, in from_pretrained
raise EnvironmentError(
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.
Failed to create model quickly; will retry using slow method.
loading stable diffusion model: OSError
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 973, in _bootstrap
self._bootstrap_inner()
File "/opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/Users/wuzhanxi/stable-diffusion-webui/modules/initialize.py", line 147, in load_model
shared.sd_model # noqa: B018
File "/Users/wuzhanxi/stable-diffusion-webui/modules/shared_items.py", line 128, in sd_model
return modules.sd_models.model_data.get_sd_model()
File "/Users/wuzhanxi/stable-diffusion-webui/modules/sd_models.py", line 531, in get_sd_model
load_model()
File "/Users/wuzhanxi/stable-diffusion-webui/modules/sd_models.py", line 643, in load_model
sd_model = instantiate_from_config(sd_config.model)
File "/Users/wuzhanxi/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py", line 89, in instantiate_from_config
return get_obj_from_str(config["target"])(**config.get("params", dict()))
File "/Users/wuzhanxi/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 563, in __init__
self.instantiate_cond_stage(cond_stage_config)
File "/Users/wuzhanxi/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 630, in instantiate_cond_stage
model = instantiate_from_config(config)
File "/Users/wuzhanxi/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py", line 89, in instantiate_from_config
return get_obj_from_str(config["target"])(**config.get("params", dict()))
File "/Users/wuzhanxi/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/modules/encoders/modules.py", line 104, in __init__
self.tokenizer = CLIPTokenizer.from_pretrained(version)
File "/opt/homebrew/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1809, in from_pretrained
raise EnvironmentError(
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.
原因:clip-vit-large-patch14 國內(nèi)已經(jīng)不能訪問了
需要手動創(chuàng)建openai 目錄并把 下載后解壓的資源拖入到openai目錄下面
安裝sd的時候,本地你自己的目錄下會同時生成一個sd的目錄,我的是這樣的
/Users/wuzhanxi/stable-diffusion-webui,在這個目錄下手動創(chuàng)建一個openai目錄
可以用的模型的代碼:
鏈接: https://pan.baidu.com/s/1EBptJ2v9inq9A5LEYFfBMg 提取碼: dh2b
報錯三: Couldn’t install gfpgan.
在執(zhí)行完 ./webui.sh 后報 “RuntimeError: Couldn’t install gfpgan.”
其實是因為沒有下載下來 gfpgan。我們可以從報錯信息中找到下載鏈接,如下圖中橫線部分。
然后 copy 這個鏈接到瀏覽器中進(jìn)行下載,然后將下載好的 zip 文件加壓,并將目錄名改成 GFPGAN,然后拖到 stable-diffusion-webui 這個目錄下就好了。文章來源:http://www.zghlxwxcb.cn/news/detail-829464.html
當(dāng)再次執(zhí)行 ./webui.sh 時,發(fā)現(xiàn)已經(jīng)跨過下載 GFPGAN,繼續(xù)下載其他依賴了。文章來源地址http://www.zghlxwxcb.cn/news/detail-829464.html
到了這里,關(guān)于m2安裝stable-diffusion報錯及解決方案的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!