当前位置: 代码网 > it编程>前端脚本>Python > centos 安装 stable-diffusion 详细流程

centos 安装 stable-diffusion 详细流程

2024年07月28日 Python 我要评论
一、安装git 新版先安装git 工具来更新git源码 , 载下源码后卸载git 版本(centos 默认1.8版本,说是安装会引起失败)安装git 命令,可使用 git --version查看版本卸载git命令正式源码安装git 过程最后显示 git version 2.44 就成功了(要git 2.3以上)二、安装python(较新版本的Python不支持torch)-官方要求的 (注:不可卸载自带python-中间心酸自己知道)

 一、准备环境

 先安装git 工具来更新git源码 , 载下源码后卸载git 版本(centos 默认1.8版本,说是安装会引起失败)

安装git 命令,可使用 git --version查看版本

sudo yum install git -y

卸载git命令

sudo yum remove git

 正式源码安装git 过程 

cd /usr/src/
git clone https://github.com/git/git.git
cd git/
sudo make prefix=/usr install
sudo echo "export path=/usr/bin:$path" >> ~/.bashrc
source ~/.bashrc
git --version

最后显示 git version 2.44 就成功了(要git 2.3以上)

cd /usr/local
wget https://www.python.org/ftp/python/3.10.6/python-3.10.6.tgz --no-check-certificate
tar -zxvf python-3.10.6.tgz
wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz --no-check-certificate
tar -zxvf openssl-1.1.1n.tar.gz
cd openssl-1.1.1n
./config --prefix=/usr/local/openssl
make -j && make install
openssl version

mv /usr/bin/openssl /usr/bin/openssl.bak
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

yum install zlib zlib-devel
yum install -y libffi-devel

cd /usr/local/python-3.10.6/
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl --with-openssl-rpath=auto
make -j
make install
python3 -v

ln -s /usr/local/python3/bin/pydoc3.10 /usr/bin/pydoc3
ln -s /usr/local/python3/bin/python3.10-config /usr/bin/python3-config
ln -s /usr/local/python3/bin/python3.10 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.10 /usr/bin/pip

pip install --upgrade pip

pip -v
pip install requests

 说明:

安装完python3.10.6  ,

        pip 安装默认为 22.2.1 要升级到最新

在webui.sh中把 can_run_as_root=0 改成 can_run_as_root=1   就可以root 直接执行对应脚本 

 说明:(pip在虚拟机中可能不是最新的,所以创建要创建的虚拟机中,升级pip)

第一步安装git和python3在前置部分已经安装好了。
开始第二步,下载webui.sh,下面这个命令即使从官方github地址下载webui.sh这个文件。注意:我们只需要下载这一个文件即可,其他文件在之后执行这个文件的时候会下载。
wget -q https://raw.githubusercontent.com/automatic1111/stable-diffusion-webui/master/webui.sh
第三步执行webui.sh,在你保存webui.sh的目录中执行。执行完成后,会在同级目录下生成名为stable-diffusion-webui的文件夹,这就是从官方地址完整下载的。
./webui.sh
第四部进入stable-diffusion-webui里面,里面也有这个文件,再次执行这个./webui.sh文件,然后就可以使用啦

wget -q https://raw.githubusercontent.com/automatic1111/stable-diffusion-webui/master/webui.sh

sh webui.sh
cd stable-diffusion-webui
python3 -m venv venv
source venv/bin/activate
pip -v 
pip install --upgrade pip

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

pip install -r requirements_versions.txt # 执行此条命令前,请检查你的剩余磁盘空间

 二、安装必要的库  在stable-diffusion-webui目录

pip3 install torch torchvision torchaudio
python -m xformers.info
 
pip install xformers
mkdir openai
cd openai
git clone https://www.modelscope.cn/ai-modelscope/clip-vit-large-patch14.git
git clone https://github.com/facebookresearch/xformers.git
cd xformers
git submodule update --init --recursive
 
如果不行,也可以用下源码,下下来放对应目录 
 
git clone https://github.com/nvidia/cutlass.git third_party/cutlass
git clone https://github.com/dao-ailab/flash-attention.git third_party/flash-attention
git clone https://github.com/rocm/composable_kernel.git third_party/composable_kernel_tiled

cd ./repositories
git clone https://github.com/salesforce/blip.git
git clone https://github.com/sczhou/codeformer.git
git clone https://github.com/crowsonkb/k-diffusion.git
git clone https://github.com/stability-ai/generative-models.git
git clone https://github.com/stability-ai/stablediffusion.git stable-diffusion-stability-ai


git clone https://github.com/compvis/stable-diffusion.git
cd stable-diffusion

参考:

1)、centos7 部署 stable diffusion_skip-torch-cuda-test-csdn博客

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com