1.安装环境
操作系统及版本:Ubuntu 20.04.5 GPU: 8GB
GPU驱动(我是阿里云GPU服务器)
Linux手动安装GPU驱动参考:https://docs.nvidia.com/datacenter/tesla/tesla-installation-notes/index.html?spm=a2c4g.11186623.0.0.2d45639cNEukDR
下载链接:https://www.nvidia.com/Download/Find.aspx?spm=a2c4g.11186623.0.0.503f573bVfJPKT&lang=cn
2.配置pip国内源(因为需要下载大量包)
vim ~/.pip/pip.conf [global] index-url=http://mirrors.cloud.aliyuncs.com/pypi/simple/ [install] trusted-host=mirrors.cloud.aliyuncs.com
3.安装python 3.10.6
#可以使用其他版本,不怕作死的话
wget http://www.openssl.org/source/openssl-1.1.1.tar.gz tar xf openssl-1.1.1.tar.gz cd openssl-1.1.1/ ./config --prefix=/usr/local/openssl shared zlib make && make install # ubuntu vim .bashrc export LD_LIBRARY_PATH=/usr/local/openssl/lib:/usr/local/cuda-11.4/lib64:$LD_LIBRARY_PATH #centos echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/openssl/lib" >> ~/.bash_profile tar -xf Python-3.10.6.tar cd Python-3.10.6 ./configure --prefix=/usr/local/python3 --with-ssl=/usr/local/openssl #启用SSL,否则后面运行时会报错 make && make install vim ~/.bashrc #centos应当~/.bash_profile export PATH=/usr/local/python3/bin:/usr/local/cuda-11.4/bin:$PATH . ~/.bashrc python3 -m pip install --upgrade pip #升级pip
4.安装Git
apt-get install git
5.安装依赖(重要)
pip3 install transformers==4.24.0 #具体版本参考官方文档,文档最后 pip3 install diffusers==0.7.2
pip3 install cython==0.29.33 #0.29.33是我实验出来的,版本可以不加,安装默认版本应该也可以
pip3 install fastapi==0.90.1
扩展命令:
pip show package_name 查看已安装package信息
pip install package_name=xxxxxxxxx #就是xxxxxxxxx,查看package所有版本,报错后展示
6.下载模型文件
https://huggingface.co/IDEA-CCNL/Taiyi-Stable-Diffusion-1B-Chinese-v0.1/tree/main
7.下载项目
mkdir /ai cd /ai git clone https://github.com/IDEA-CCNL/stable-diffusion-webui.git cd stable-diffusion-webui
8.安装配置(按需)
8.1 设置允许root运行
vim webui.sh
8.2 使用自定义python解释器
#不指定脚本会自动根据系统现有解释器生成,安装过程可能会有点小问题
vim webui-user.sh python_cmd="/usr/local/python3/bin/python3"
9.运行
bash webui.sh #国内网速估计不低于20分钟,会自动下载相关包及模块 #先选1 repositories/Taiyi-Stable-Diffusion-1B-Chinese-v0.1 does not exist or file is missing. (1)Do you want to redownload the Taiyi model? Or (2)move your downloaded Taiyi model path? 1/2: 1 #将第四步下载的模型文件分别拷贝到以下两个目录,替换同名文件 #repositories/Taiyi-Stable-Diffusion-1B-Chinese-v0.1/ #repositories/Taiyi-Stable-Diffusion-1B-Chinese-v0.1/text_encoder/ #选择y Please move the Taiyi model to: repositories/Taiyi-Stable-Diffusion-1B-Chinese-v0.1. Completed? y: #报错不影响可以忽略
访问
Running on local URL: http://0.0.0.0:12345 #根据提示
10.运行方式修改为后台(ckpt文件必须绝对路径)
nohup python3 /ai/stable-diffusion-webui/launch.py --ckpt /ai/stable-diffusion-webui/repositories/Taiyi-Stable-Diffusion-1B-Chinese-v0.1/Taiyi-Stable-Diffusion-1B-Chinese-v0.1.ckpt --listen --port 12345 &> stable-diffusion.log &
11.其他问题
ModuleNotFoundError: No module named '_lzma'
我的解决方法
cp /usr/lib/python3.8/lib-dynload/_lzma.cpython-38-x86_64-linux-gnu.so /usr/local/python3/lib/python3.10/lib-dynload/_lzma.cpython-310-x86_64-linux-gnu.so #我的系统之前默认安装了python3.8 chmod +x /usr/local/python3/lib/python3.10/lib-dynload/_lzma.cpython-310-x86_64-linux-gnu.so
如果系统没有自带,可以参考以下方法(未验证)
参考文档:https://blog.csdn.net/Bolly_He/article/details/119750618
Ubuntu pip install backports.lzma iblzma-dev libbz2-dev
CentOS
yum install xz-devel python-backports-lzma pip install backports.lzma
搜索系统是否存在: find / -name "_lzma.cpython.*" -type f
项目文档:https://github.com/IDEA-CCNL/stable-diffusion-webui
模型文档:https://huggingface.co/IDEA-CCNL/Taiyi-Stable-Diffusion-1B-Chinese-v0.1
标签:diffusion,Taiyi,usr,install,Linux,pip,local,webui From: https://www.cnblogs.com/panwenbin-logs/p/17147056.html