显卡:AMD RX6700 XT 12GB 华擎幻影电竞
处理器:AMD R5 3500X 6C6T
主板: 华硕TUF B450M-PRO GAMING
###安装git、vim
cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo gedit sources.list
-------------------删掉原来全部内容,把下面这段复制进去,最后记得保存!!!----------------------------------------
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-security multiverse main universe restricted
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates multiverse main universe restricted
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install wget git vim python3-pip python3-venv
sudo mkdir ~/.pip&&touch ~/.pip/pip.conf&&echo -e '[global]\nindex-url=https://pypi.douban.com/simple\ntimeout = 6000\n[install]\ntrusted-host=pypi.douban.com\n#disable-pip-version-check = true' > ~/.pip/pip.conf
###安装对应Ubuntu 22.04版本的A卡驱动
wget http://repo.radeon.com/amdgpu-install/22.40.6/ubuntu/jammy/amdgpu-install_5.4.50406-1_all.deb sudo apt-get install ./amdgpu-install_5.4.50406-1_all.deb
---------------注意!!!如果你是其他系统版本,需要自己根据版本号。进入这个链接找:http://repo.radeon.com/amdgpu-install/
sudo amdgpu-install --no-dkms sudo apt-get install rocm-smi-lib
/opt/rocm/bin/rocm-smi
/opt/rocm/bin/rocminfo
/opt/rocm/opencl/bin/x86_64/clinfo
echo 'export PATH=$PATH:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin/x86_64' | sudo tee -a /etc/profile.d/rocm.sh
apt show rocm-libs -a #查看ROCm版本
watch -n 1 /opt/rocm/bin/rocm-smi #实时显卡监控
sudo usermod -a -G video $LOGNAME sudo usermod -a -G render $LOGNAME
echo 'ADD_EXTRA_GROUPS=1' | sudo tee -a /etc/adduser.conf echo 'EXTRA_GROUPS=video' | sudo tee -a /etc/adduser.conf
/opt/rocm/bin/rocm-smi --setperflevel high
------------注意:这将会让你的卡保持高频率运转,如果你短期不想画图了,可以设为auto,更省电
/opt/rocm/bin/rocm-smi --setperflevel auto
sudo apt install cpupower-gui
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
less webui.sh
# Check prerequisites gpu_info=$(lspci 2>/dev/null | grep VGA) case "$gpu_info" in *"Navi 1"*|*"Navi 2"*) export HSA_OVERRIDE_GFX_VERSION=10.3.0 ;; *"Renoir"*) export HSA_OVERRIDE_GFX_VERSION=9.0.0 printf "\n%s\n" "${delimiter}"
if echo "$gpu_info" | grep -q "AMD" && [[ -z "${TORCH_COMMAND}" ]] then export TORCH_COMMAND="pip install torch==2.0.1+rocm5.4.2 torchvision==0.15.2+rocm5.4.2 --index-url https://download.pytorch.org/whl/rocm5.4.2" fi
cd stable-diffusion-webui/
python3 -m venv venv
./webui.sh
RuntimeError: Couldn't clone K-diffusion. Command: "git" clone "https://github.com/crowsonkb/k-diffusion.git" "/home/terryjay/SD/stable-diffusion-webui/repositories/k-diffusion" Error code: 128 stderr: 正克隆到 '/home/terryjay/SD/stable-diffusion-webui/repositories/k-diffusion'... fatal: 无法访问 'https://github.com/crowsonkb/k-diffusion.git/':Failed to connect to github.com port 443 after 130035 ms: 连接超时`
No checkpoints found. When searching for checkpoints, looked at: - file /home/terryjay/SD/stable-diffusion-webui/model.ckpt - directory /home/terryjay/SD/stable-diffusion-webui/models/Stable-diffusion Can't run without a checkpoint. Find and place a .ckpt or .safetensors file into any of those locations. The program will exit. Running on local URL: http://127.0.0.1:7860 To create a public link, set `share=True` in `launch()`. Startup time: 4.6s (import torch: 0.7s, import gradio: 1.3s, import ldm: 1.0s, other imports: 0.5s, list SD models: 0.2s, load scripts: 0.4s, create ui: 0.3s).
1. 下载的是checkpoint (缩写ckpt) 或safetensors 类型的文件,都放入“stable-diffusion-webui\models\Stable-diffusion”中
2. LoRA类型放入“stable-diffusion-webui\models\Lora”中
3. hypernetwork类型放在“stable-diffusion-webui\models\hypernetworks”中
controlnet放在“/stable-diffusion-webui/extensions ”中
###如果环境出现问题,可手动验证能否识别pytorh:
import torch
torch.cuda.is_available()