阿里云的GPU服务器搭建SD服务器

1  搭建基本环境
yum install epel-release -y
yum update -y
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
yum -y install ffmpeg ffmpeg-devel
yum install  -y git 

下载Anaconda
wget  https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh
如果没有wget则可以通过以下命令安装yum install wget -y
2、安装Anaconda
增加执行权限: chmod +x Anaconda3-2023.03-1-Linux-x86_64.sh 
开始执行:./Anaconda3-2023.03-1-Linux-x86_64.sh
3 创建虚拟环境:conda create -n sd  python=3.10.6
切换到SD:conda activate sd
4  安装git      conda install git

############################################################
 https://pypi.org/simple   --trusted-host   pypi.org/simple

4   下载代码stable-diffusion-webui
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui

5  开始安装需要的环境 
cd stable-diffusion-webui/
6  注意转换一下文件格式

     yum install  dos2unix
    dos2unix requirements_versions.txt 
    dos2unix requirements.txt 
7 开始安装需要的python环境( 指定源)
  awk  '{print "  pip   install  " $1  " -i  https://pypi.org/simple   --trusted-host   pypi.org/simple "}' requirements_versions.txt |sh
 
8  出现问 ERROR: No matching distribution found for cython
   pip install cython

9 安装需要的环境
awk  '{print "  pip   install  " $1  " -i  https://pypi.org/simple   --trusted-host   pypi.org/simple "}' requirements.txt |sh

10 修改启动脚本(webui.sh )
 删除下面部分(使用root运行)
# Do not run as root
if [[ $(id -u) -eq 0 && can_run_as_root -eq 0 ]]
then
    printf "\n%s\n" "${delimiter}"
    printf "\e[1m\e[31mERROR: This script must not be launched as root, aborting...\e[0m"
    printf "\n%s\n" "${delimiter}"
    exit 1
else
    printf "\n%s\n" "${delimiter}"
    printf "Running on \e[1m\e[32m%s\e[0m user" "$(whoami)"
    printf "\n%s\n" "${delimiter}"
fi

11 开始启动系统(第一次启动默认下载安装包)
   sh webui.sh 
#  默认下载的模型的远端地址
https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
下载到的不本地地址
/app/sd/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors
#  开启远端访问
sh webui.sh  --listen
 

###############

kohya_ss  安装

#  下载文件
git clone https://github.com/bmaltais/kohya_ss.git
cd kohya_ss
#  安装需要的环境
awk  '{print "  pip   install  " $1  " -i  https://pypi.org/simple   --trusted-host   pypi.org/simple "}' requirements_linux.txt |sh
awk  '{print "  pip   install  " $1  " -i  https://pypi.org/simple   --trusted-host   pypi.org/simple "}' requirements.txt |sh
yum install  -y python3-tkinter
# 运行安装脚本

sh setup.sh 
# 需要下载的文件如下
16:03:57-174553 INFO     Installing modules from requirements_linux.txt...                                                                                                                   

# 启动的脚步如下(注意使用参数)
python kohya_gui.py --listen 0.0.0.0 --server_port 7861 --inbrowser --share
 

#######################

facefusion 安装

git clone https://github.com/facefusion/facefusion.git
awk  '{print "  pip   install  " $1  " -i  https://pypi.org/simple   --trusted-host   pypi.org/simple "}' requirements.txt |sh
yum  -y groupinstall 'Development Tools'
pip install typing-extensions --upgrade 
pip install tb-nightly -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
#(选默认不使用CUDA  设计到CUAD版本必须是11。8 cudnn版本是8.6.0 环境比较难以搭建)
python  install.py
#  解决so的问题
export LD_LIBRARY_PATH=/root/anaconda3/envs/sd/lib/python3.10/site-packages/nvidia/nvjitlink/lib/:$LD_LIBRARY_PATH
 
#  启动程序(注意第一次启动需要下载文件)
python  run.py 

注意补充,如果想共享给其它人用,需要修改\facefusion\uis\layouts\default.py的最后一行。
def run(ui : gradio.Blocks) -> None:
 ui.launch(show_api = False,share=True,server_name="0.0.0.0")

##############

注意 如果使用代理 需要增加下面的参数

export no_proxy="localhost, 127.0.0.1, ::1"
set no_proxy environment variable on linux shell:
export no_proxy="localhost, 127.0.0.1, ::1"

或者修改代码
or add this line in your app python code:
os.environ["no_proxy"] = "localhost,127.0.0.1,::1"

###################

stable diffusion反推提示词出现此提示时,需安装以下模型至sd-webui-aki-v4.cache\clip\目录

https://openaipublic.azureedge.net/clip/models/b8cca3fd41ae0c99ba7e8951adf17d267cdb84cd88be6f7c2e0eca1737a03836/ViT-L-14.pt

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值