CentOS 默认源很慢,先换源:
# CentOS 7
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache或使用清华源(推荐服务器):
https://mirrors.tuna.tsinghua.edu.cn/help/centos/yum update -ysetenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/configCentOS 自带 Python 很旧(2.7 / 3.6),会巨慢。
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh创建专用环境:
conda create -n sd python=3.10 -y
conda activate sdpip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple或临时:
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simplenvidia-smi若无输出,安装驱动(CentOS):
yum install -y gcc kernel-devel
sh NVIDIA-Linux-x86_64-*.runStable Diffusion 常用:
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia验证:
python -c "import torch; print(torch.cuda.is_available())"True 才算成功git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd stable-diffusion-webuiexport COMMANDLINE_ARGS="--xformers --no-half-vae"启动:
./webui.sh--xformers # 显存 & 速度提升(必须)
--medvram # 显存 < 8G
--lowvram # 显存 < 4G
--opt-sdp-attentionmv models /data/ssd/models
ln -s /data/ssd/models ~/stable-diffusion-webui/models.safetensorsexport HF_ENDPOINT=https://hf-mirror.comgit config --global url."https://ghproxy.com/https://github.com/".insteadOf "https://github.com/"| 问题 | 解决 |
|---|---|
| glibc 太低 | 用 conda 环境 |
| 缺少 libGL | yum install mesa-libGL |
| 端口不通 | 防火墙放行 |
| 中文乱码 | 安装中文字体 |
✅ 必做项
✅ 提速效果
如果你愿意,我可以:
你现在的 CentOS 版本 + 显卡型号 是多少?