系統(tǒng)環(huán)境
Ubuntu 20.04.6 LTS
Python系統(tǒng)自帶3.8版本(雖然官方要求3.10.6,但是我3.8運行沒發(fā)現(xiàn)問題)
顯卡RX6500XT 4G Navi24核心
AMD顯卡驅(qū)動
官網(wǎng)下載安裝在下載好的驅(qū)動文件目錄,執(zhí)行安裝命令
sudo apt install ./amdgpu-install_5.4.50403-1_all.deb
鏡像源 更新
先將源列表文件sources.list備份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
打開sources.list文件
sudo gedit /etc/apt/sources.list
替換為國內(nèi)鏡像源,保存 這里我用阿里云的鏡像源 https://developer.aliyun.com/mirror/ubuntu
#ubuntu 20.04(focal)
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal universe main restricted multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal universe main restricted multiverse
更新
sudo apt-get update
sudo apt-get upgrade
Clash安裝
防止獲取某些軟件包時連接超時,下載速度也快些,后面遇到下載失敗情況可以嘗試開啟全局代理
顯卡ROCM環(huán)境
安裝ROCM
sudo amdgpu-install --no-dkms
sudo apt install rocm-dev
將用戶添加進組,重啟
ls -l /dev/dri/render*
sudo usermod -a -G render $LOGNAME
sudo usermod -a -G video $LOGNAME
sudo reboot
檢驗安裝ROCM
運行下面的指令,報錯說明安裝失敗
rocm-smi
/opt/rocm/bin/rocminfo
/opt/rocm/opencl/bin/clinfo
安裝Miopen
A卡有兩種安裝方式,miopen-hip或miopen-opencl,我這里選擇hip
sudo apt-get install miopen-hip
下載miopen內(nèi)核,適用于gfx1030(RX6800)的a卡,Rocm4.5.2目前確定支持gfx1030,其他6000系型號不一定支持,我的顯卡是gfx1034(RX6500XT),可以偽裝成gfx1030去跑。
sudo apt-get install miopenkernels-gfx1030-36kdb
Stable-Diffusion-WebUI
下載Stable-Diffusion-WebUI
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
到下載好的stable-diffusion-webui文件夾里找到launch.py文件,編輯文件找到這一行這是有CUDA核心的N卡安裝Pytorch1.13.1的指令,A卡要改成安裝Pytorch2.0.0 Rocm4.5.2版本的指令,打開Pytorch官網(wǎng)
用官網(wǎng)這段命令替換原來的命令,保存退出文件,啟動table-diffusion-webui的時候會自動下載Pytorch2.0.0
啟動stable-diffusion-webui
還是在stable-diffusion-webui目錄下,執(zhí)行啟動命令文章來源:http://www.zghlxwxcb.cn/news/detail-430750.html
HSA_OVERRIDE_GFX_VERSION=10.3.0 python3 launch.py
如果出現(xiàn)報錯:
Installing torch and torchvision
Argument expected for the -m option
usage: /usr/local/bin/python 【option】 ... 【-c cmd | -m mod | file | -】 【arg】 ...
Try `python -h' for more information.
Traceback (most recent call last):
File "/home/ailfreedom/stable-diffusion-webui/launch.py", line 351, in <module>
prepare_environment()
File "/home/ailfreedom/stable-diffusion-webui/launch.py", line 253, in prepare_environment
run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
File "/home/ailfreedom/stable-diffusion-webui/launch.py", line 81, in run
raise RuntimeError(f"""{errdesc or 'Error running command'}.
RuntimeError: Couldn't install torch.
Command: "/usr/local/bin/python" -m
Error code: 2
就嘗試執(zhí)行手動安裝:
python3 -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.4.2
如果出現(xiàn)報錯:
ValueError: Unknown scheme for proxy URL URL('socks://127.0.0.1:7890/')
說明代理或端口出錯,執(zhí)行解除所有代理命令:
unset all_proxy; unset ALL_PROXY
如果出現(xiàn)報錯:
No checkpoints found. When searching for checkpoints, looked at:
- file /home/hys/stable-diffusion-webui/model.ckpt
- directory /home/hys/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.
說明加載不到模型文件,
在huggingface.co或civitai.com網(wǎng)站下載模型,比如我下載stable-diffusion-v1-4的模型文件,放到stable-diffusion-webui/models/Stable-diffusion文件夾下,就可以加載了
顯示URL http://127.0.0.1:7860說明啟動成功文章來源地址http://www.zghlxwxcb.cn/news/detail-430750.html
其他
顯卡監(jiān)控
#顯卡監(jiān)控
watch -n 1 rocm-smi
(1表示每隔1秒刷新)
#如果想顯示更詳細的信息,安裝AMD的radeontop監(jiān)控軟件
sudo apt install mesa-utils radeontop
sudo radeontop
查看pytorch版本:
python3
import torch
torch.__version__
#返回'2.0.0+rocm5.4.2'即AMD顯卡用的ROCM版本,如果是N卡版本返回應該像'2.0.0+cu117'
查看cuda是否可用
python3
import torch
torch.cuda.is_available()
#True即可用,F(xiàn)alse不可用
啟動命令參數(shù)
啟動命令后面可以帶參數(shù),常用參數(shù)
(完整參數(shù)含義可以在官網(wǎng)查詢:https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Command-Line-Arguments-and-Settings)
--precision full #啟用全精度浮點運算
--no-half #啟用半精度浮點運算
--medvram #6G/8G顯存爆顯存的話加上這個
--lowvram #4G顯存爆顯存的話加上這個
--always-batch-cond-uncond #禁用批量生成圖片
--xformers #優(yōu)化顯存占用的插件,需額外安裝
HSA_OVERRIDE_GFX_VERSION=10.3.0 python3 launch.py --lowvram --always-batch-cond-uncond
到了這里,關于AMD顯卡 Ubuntu 部署Stable DIffusion WebUI基于Pytorch2.0.0 Rocm5.4.2的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!