前言

心血来潮,买了一张 3080 20G ,遂安装ubnutu。

以下东西不保证完整,想到啥写啥。

踩坑(过程)统计

* 软件安装类问题
* 显卡驱动安装
* 网络问题
* stable diffusion相关
* 稀奇古怪的问题

软件安装类问题

这部分踩坑如下:

安装慢

很显然是要换源。

sudo vi /etc/apt/sources.list

在里面设置

1
2
3
4
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

注意 jammy 是 ubnutu22 的代号,其他版本有自己的代号,代号没弄对会导致可能没有适配的版本。

没有适配的版本

针对于sd来说,不能使用清华镜像,因为清华镜像有个东西(忘了叫啥)没有适配版本。

还有刚才提到的原因也会导致此问题。

网络问题

更改 DNS,重启后 DNS 变回来了

首先查看有没有 /etc/systemd/resolved.conf

没有的话 sudo apt-get install resolvconf

然后使用编辑器打开 /etc/systemd/resolved.conf

输入 DNS=223.5.5.5 223.6.6.6 (这个是阿里的 dns,你也可以换成其他的 dns,最好不要超过三个)

1
2
3
4
5
sudo su
systemctl restart systemd-resolved
systemctl enable systemd-resolved
mv /etc/resolv.conf /etc/resolv.conf.bak
ln -s /run/systemd/resolve/resolv.conf /etc/

就可以了。

显卡驱动安装

本人显卡 3080 20G,首先在官网下载好驱动后。

安装 make 和 gcc

1
2
sudo apt install make
sudo apt install gcc

我直接把下载好的 .run 文件重命名成了 N535.run 于是

sudo bash N535.run --no-x-check

如果出现 nouveau 或者 onpengl 相关问题自行解决,因为我没遇到(

能输出 nvidia-smi 即视为成功

pP3rD4P.png

stable-diffusion 相关

下载 sd

首先 git clone 下来地址

git clone https://github.com/Stability-AI/stablediffusion

没有 gitsudo apt install git

然后你要需要下载一个 .ckpl 模型,这个是用来跑图片的模型。

这hugging face 这里面可以下载 https://huggingface.co/stabilityai/stable-diffusion-2-1/tree/main

下载完毕后把文件放在 /stable-diffusion-webui/models/Stable-diffusion 下面。

安装相关依赖

然后 cd 进去

pip install -r requirements.txt

需要注意的是,这里 requirement 并不完全,例如没有 torchvision,tdqm,xformers,virtualenv,scipy,sklearn等等,除非这台机器之前有机器学习过。等一下你启动webui后报错需要 pip install 这些模块。

这里说一下 torch 安装,建议直接 2.0.1 我弄 2.0.0+cu118 死活安装不了 0.15+cu118torchvision

启动 webui

webui 不能以 root 身份启动 bash webui.sh 即可启动,第一次启动大概率失败。先别急,把里面的 github 地址换成镜像地址先。

打开 /stable-diffusion-webui/modules 编辑 gfpgan_model.pylaunch_utils.py 把里面所有的 https://github.com 开头的网址改写成 https://ghproxy.com/https://github.com 开头。

如果提示 CAfile: none CRLfile: none

1
2
git config --global http.sslverify false
git config --global https.sslverify false

稀奇古怪的问题

键盘输入延迟巨大

1
2
ibus restart
ibus-daemon -r -d -x

cpu某个核心吃满导致系统极其卡顿。