【AIGC】阿里云ecs部署stable diffusion

文章目录

安装anaconda

安装Python、wget、git

sudo apt install python3 python3-pip python3-virtualenv wget git

安装前置依赖

sudo apt-get install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6

下载anaconda

wget https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh

创建Python 3.10.6的虚拟环境

conda create --name sdwebui python=3.10.6

安装cuda

os=ubuntu2004

arch=x86_64

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb

sudo dpkg -i cuda-keyring_1.0-1_all.deb

sudo apt update

sudo apt install cuda-11-8

git 加速

开启加速

export http_proxy=http://172.181.217.43:12798 && export https_proxy=http://172.181.217.43:12798

关闭加速

unset http_proxy && unset https_proxy

【todo:注意关闭配置】https://blog.csdn.net/zhiboqingyun/article/details/123912058

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

配置虚拟环境

bash 复制代码
启动虚拟环境
conda activate sdwebui

如果想要于bash script自动以conda启动虚拟环境,可以把这二行加入至webui-user.sh顶端:
eval "$(conda shell.bash hook)"
conda activate sdwebui

下载模型
wget -nc -P ~/stable-diffusion-webui/models/Stable-diffusion https://huggingface.co/andite/anything-v4.0/resolve/main/anything-v4.5-pruned.safetensors -O anything-v4.5-pruned.safetensors

首次启动
./webui.sh 
# 或
./webui.sh --xformers --skip-install --enable-insecure-extension-access

挂载oss

https://help.aliyun.com/document_detail/153892.html?spm=a2c4g.153893.0.0.1d877f1fHkYVYt

端口开放

https://www.bilibili.com/read/cv23060248

启动服务时需要添加 --listen参数

./webui.sh --listen

sed -i 's/can_run_as_root=0/can_run_as_root=1/g' webui.sh &&

./webui.sh --no-download-sd-model --xformers

启动后的一些权限问题

sudo chown -R root stable-diffusion-webui

sudo chgrp -R root stable-diffusion-webui

服务地址:http://xx.xx.xx.xx:7860/

启动服务

sudo ./webui.sh --listen --skip-install --enable-insecure-extension-access

其他

controlnet

https://github.com/Mikubill/sd-webui-controlnet/issues/1399

Package cairo was not found in the pkg-config search path.

Perhaps you should add the directory containing `cairo.pc'

to the PKG_CONFIG_PATH environment variable

No package 'cairo' found

ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects

sudo apt install libcairo2-dev

I fixed itby this way:

  1. run command below on linux

    sudo apt install libcairo2-dev

  2. install svglib package manually or relaunch webui

    pip install svglib

显卡使用监控

watch -n 1 nvidia-smi

参考资料

查看Linux服务器配置|是否有GPU以及GPU信息:https://blog.csdn.net/qq_41725313/article/details/123784429

安装至Linux:https://ivonblog.com/posts/stable-diffusion-webui-manuals/zh-cn/installation/linux-installation/

安装驱动:https://ivonblog.com/posts/ubuntu-install-nvidia-drivers/

安装驱动(阿里云官方文档):https://help.aliyun.com/document_detail/163824.htm?spm=a2c4g.298150.0.0.1e0b5355t3jXPh#concept-ecy-qrz-wgb

相关推荐
肖遥Janic14 小时前
Stable Diffusion绘画 | 插件-Deforum:动态视频生成(上篇)
人工智能·ai·ai作画·stable diffusion
肖遥Janic16 小时前
Stable Diffusion绘画 | 插件-Deforum:商业LOGO广告视频
人工智能·ai·ai作画·stable diffusion
学习前端的小z1 天前
【AIGC】ChatGPT提示词解析:如何打造个人IP、CSDN爆款技术文案与高效教案设计
人工智能·chatgpt·aigc
wgggfiy2 天前
chatgpt学术科研prompt模板有哪些?chatgpt的学术prompt有哪些?学术gpt,学术科研
论文阅读·人工智能·gpt·chatgpt·prompt·aigc
⊙月2 天前
CMU 10423 Generative AI:lec15(Scaling Laws 大规模语言模型的扩展法则)
人工智能·aigc
贪玩懒悦2 天前
用langchain+streamlit应用RAG实现个人知识库助手搭建
人工智能·ai·语言模型·langchain·aigc
sleetdream2 天前
Pycharm 本地搭建 stable-diffusion-webui
stable diffusion
chenkangck502 天前
AI大模型之旅-最强开源文生图工具Stable Diffusion WebUI 教程
人工智能·stable diffusion
CM莫问2 天前
大语言模型入门(一)——大语言模型智能助手
人工智能·算法·语言模型·自然语言处理·aigc
小龙在山东2 天前
基于Flux的文生高清图片
stable diffusion·flux