> 技术文档 > Stable diffusion 本地部署加载模型报 openai/clip-vit-large-patch14 错误的解决方法

Stable diffusion 本地部署加载模型报 openai/clip-vit-large-patch14 错误的解决方法


1. 报错描述

本地部署好 Stable diffusion 以后,点击加载模型时报 openai/clip-vit-large-patch14 错误,具体报错信息如下:

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

2. 报错原因

连不上huggingface,无法下载模型。

3. 解决方法

1)手动下载 clip-vit-large-patch14 相关文件,可以去官网下载。

2)在本地磁盘中创建 openai 目录;

3)将下载的文件解压缩放入 openai 目录中;

4)打开本地安装目录中的 tokenization_utils_base.py 文件,文件路径为:\\stable-diffusion-webui\\venv\\Lib\\site-packages\\transformers 

5)在文件中搜索 pretrained_model_name_or_path =,修改等号后面的路径为第 3 步中 clip-vit-large-patch14 的路径。例如:

6)打开 \\stable-diffusion-webui\\repositories\\stable-diffusion-stability-ai\\ldm\\modules\\encoders 路径下的 modules.py 文件,修改路径,具体如下(有两处):

第 1 处:

第 2 处:

7. 重启 SD ,重启后再次加载模型,已经可以加载出来了:

#Stable diffusion