Stable Diffusion Web 环境搭建
默认你的系统Ubuntu、CUDA、Conda等都存在,即具备运行深度学习模型的基础环境
本人:Ubuntu22.04、CUDA11.8
环境搭建
- 克隆项目并且创建环境
https://github.com/AUTOMATIC1111/stable-diffusion-webui
conda create -n sd python=3.10
- 运行过程自动安装依赖
python launch.py
- 网络、访问等问题必然会出现中断(缺啥下啥)
- clip
pip install git+https://github.com/openai/CLIP.git
- generative-models launch过程中失败,单独clone就成功了,launch.py会拉去很多库,失败就手动拉一下就好
~/stable-diffusion-webui-master/repositories$git clone https://github.com/Stability-AI/generative-models.git
- 需要手动安装的,不装也可以。这是一个加速 attention 的可选库,缺失会让推理稍慢一点,但不影响使用。如果想启用,可手动安装:
pip install xformers
- 到这里我就已经可以访问web了,但是生成报错如下
- 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.
- 分析应该是访问huggingface的网络问题导致
pip install huggingface_hub
export HF_ENDPOINT=https://hf-mirror.com
重新启动,解决所有问题。运行成功。。撒花
效果展示
总结
官方还提供bash webui-user.sh的方法,他会多一步帮你直接创建conda环境,反正我这里感觉很难成功没有使用。而且失败就要全部从头安装,感觉国内不太友善。