默認你的系統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環境,反正我這里感覺很難成功沒有使用。而且失敗就要全部從頭安裝,感覺國內不太友善。