FinalShell是一款服务器管理工具,支持SSH和远程桌面,提供多标签管理、命令自动提示、SFTP、性能监控等功能,适用于开发运维,界面友好,在很大程度上可以免费替代XShell。
FinalShell的下载:https://www.hostbuf.com/t/988.html
名称: 自定义 主机: 填写你的服务器的公网IP 端口: 填写服务器端口 备注: 自定义 方法: 密码 用户名:默认是root 密码: 填写服务器的登录密码
新建完后双击或者右键点击连接
sudo apt-get update
sudo apt upgrade
过程中需要输入 y 或者按 Enter 键确认安装
wget https://cn.download.nvidia.com/XFree86/Linux-x86_64/550.100/NVIDIA-Linux-x86_64-550.100.run
4090对应的驱动版本为550.100,不同型号的显卡请到英伟达官网查找下载链接:https://www.nvidia.cn/Download/Find.aspx?lang=cn&QNF=1
sudo apt-get update
sudo apt-get install g++
sudo apt-get install gcc
sudo apt-get install make
sudo apt-get remove --purge nvidia*
sudo vim /etc/modprobe.d/blacklist.conf
按 i 键进入编辑模式,在文件尾增加两行:
blacklist nouveau options nouveau modeset=0
按 Esc 键退出编辑模式,输入 :wq
保存并退出
sudo cat /etc/modprobe.d/blacklist.conf
sudo update-initramfs -u
sudo reboot
有时候重启时间较长,请耐心等待,重启后再次连接
sudo chmod 777 NVIDIA-Linux-x86_64-550.100.run
sudo ./NVIDIA-Linux-x86_64-550.100.run
安装过程中需按 Enter 键确认安装
nvidia-smi
wget https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_550.54.14_linux.run
安装的显卡驱动版本是550.100,可以安装CUDA 12版本。可根据自己显卡版本选择合适的CUDA版本,查询链接:https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html
sudo chmod 777 cuda_12.4.0_550.54.14_linux.run
sudo ./cuda_12.4.0_550.54.14_linux.run
输入 accept 开始安装
注意这里要按 Enter 取消勾选第一个选项,因为之前已经安装了驱动
然后选择 Install 开始安装
sudo vim ~/.bashrc
按 i 键进入编辑模式,在文件尾增加两行:
在文件尾中加入以下两行:
export PATH="/usr/local/cuda-12.4/bin:$PATH" export LD_LIBRARY_PATH="/usr/local/cuda-12.4/lib64:$LD_LIBRARY_PATH"
按 Esc 键退出编辑模式,输入 :wq
保存并退出
source ~/.bashrc
nvcc -V
wget -c https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh
bash Anaconda3-2023.03-1-Linux-x86_64.sh
一直按 Enter 之后输入 yes 确认
注意这里要按 Enter 确认安装位置 /root/anaconda3
如有更改,后续环境变量配置路径均需更改
vim /etc/profile
按 i 键进入编辑模式,在末尾添加环境变量
export PATH="~/anaconda3/bin:$PATH"
按 Esc 键退出编辑模式,输入 :wq
保存并退出
vim ~/.bashrc
按 i 键进入编辑模式,在末尾添加环境变量
export PATH="~/anaconda3/bin:$PATH"
按 Esc 键退出编辑模式,输入 :wq
保存并退出
source /etc/profile
source ~/.bashrc
conda -V
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
sudo apt-get install libgoogle-perftools4 libtcmalloc-minimal4 -y
conda create -n sd python=3.10.6
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
https://mirror.ghproxy.com/
镜像源git clone https://mirror.ghproxy.com/https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
进入到 stable-diffusion-webui 文件夹内
cd stable-diffusion-webui
这时候直接./webui.sh
启动脚本通常会出现各种各种的问题,主要原因是国内网络问题,以下是解决方法:
使用Finalshell的文件管理功能
在/root/stable-diffusion-webui/modules
文件夹中找到 launch_utils.py
下的prepare_environment()
函数,将其中涉及到 github 仓库的依赖,全部添加 https://mirror.ghproxy.com/
镜像
按Ctrl+F查找https://github.com/
全部替换成https://mirror.ghproxy.com/https://github.com/
如下图
Ctrl+S进行保存
引入镜像地址
export HF_ENDPOINT=https://hf-mirror.com
写入到~/.bashrc中:
echo 'export HF_ENDPOINT="https://hf-mirror.com"' >> ~/.bashrc
刷新环境变量
source ~/.bashrc
/root/stable-diffusion-webui/weiui.sh
文件,将use_venv
变量值改为0,意为使用当前环境进行安装conda activate sd
pip3 install torch==2.1.2 torchvision torchaudio --extra-index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip install -r requirements.txt
./webui.sh --port 15026 --listen --enable-insecure-extension-access --xformers
--port 15026: 设置服务器监听的端口为业务端口,默认端口是7860,这里设置为15026。 --listen: 让服务器监听网络连接。这样设置后,局域网内的其他计算机可以访问UI,如果配置了端口转发,互联网上的计算机也可以访问。 --enable-insecure-extension-access: 启用扩展标签,不考虑其他选项。
更多详细的命令行参数和设置请参考https://profaneservitor.github.io/sdwui-docs/cli/
启动成功后,访问http://主机IP:端口
这里介绍一种下载方法,其余方法请参考:https://hf-mirror.com/
hfd 是huggingface 专用下载工具,基于成熟工具 git+aria2,可以做到稳定下载不断线。
wget https://hf-mirror.com/hfd/hfd.sh chmod a+x hfd.sh
apt install aria2 apt install git-lfs
开始下载
./hfd.sh gpt2 --tool aria2c -x 4
有些模型下载需要token,参数如下
--hf_username YOUR_HF_USERNAME --hf_token hf_***
token的获取:https://huggingface.co/settings/tokens
(需要VPN)
下载完后将模型移动到