331

windows环境下stable diffusion运行问题汇总

乐果   发表于   2024 年 05 月 23 日 标签:windows

当前 stable diffusion 扩散模型有两个流行的web,一个是 stable-diffusion-webui ,一个是 comfyui,在windows环境下12G显存以上的N卡都可以运行。

下面汇总一下运行过程中可能会遇到的问题。

问题1:

Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

可能是 onnxruntime-gpu, cuda, cudnn 之间的版本不匹配

可以通过如下代码验证:

>>> import onnxruntime
>>> onnxruntime.get_device()
'GPU'  #表示GPU可用
>>> onnxruntime.get_available_providers()
['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider']

如果GPU调用没问题,但是还是报上述错误,可能是torch版本与sd模型要求的版本不一致,应卸载torch后重新安装sd模型的指定版本。例如 stable diffusion webui 1.8版本中指定的torch版本为:

pip install torch==2.1.2 torchvision==0.16.2 --extra-index-url https://download.pytorch.org/whl/cu121

问题2:

ImportError: cannot import name ‘Undefined‘ from ‘pydantic.fields‘

卸载掉原来安装的

pip uninstall pydantic
Found existing installation: pydantic 2.7.1
Uninstalling pydantic-2.7.1:
  Would remove:
    c:\programdata\anaconda3\envs\sd\lib\site-packages\pydantic-2.7.1.dist-info\*
    c:\programdata\anaconda3\envs\sd\lib\site-packages\pydantic\*
Proceed (Y/n)? y
  Successfully uninstalled pydantic-2.7.1

重新安装一下旧版本

ppip install pydantic==1.10.15
Collecting pydantic==1.10.15
  Using cached pydantic-1.10.15-cp311-cp311-win_amd64.whl.metadata (152 kB)
Requirement already satisfied: typing-extensions>=4.2.0 in c:\programdata\anaconda3\envs\sd\lib\site-packages (from pydantic==1.10.15) (4.11.0)
Using cached pydantic-1.10.15-cp311-cp311-win_amd64.whl (2.1 MB)
Installing collected packages: pydantic
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
albumentations 1.4.7 requires pydantic>=2.7.0, but you have pydantic 1.10.15 which is incompatible.
Successfully installed pydantic-1.10.15

如上,又产生新的错误,因为它依赖的 albumentations 版本又不兼容。然后再卸载掉 albumentations

pip uninstall albumentations
Found existing installation: albumentations 1.4.7
Uninstalling albumentations-1.4.7:
  Would remove:
    c:\programdata\anaconda3\envs\sd\lib\site-packages\albumentations-1.4.7.dist-info\*
    c:\programdata\anaconda3\envs\sd\lib\site-packages\albumentations\*
Proceed (Y/n)? y
  Successfully uninstalled albumentations-1.4.7

再重新安装:

pip install albumentations==1.4.3
pip install pydantic==1.10.15

问题3:

Error: 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 国内已经不能访问了,开启fanqiang全局代理即可。。。

后续再补充。。。

乐果   发表于   2024 年 05 月 23 日 标签:windows

0

文章评论