目标:在Ubuntu下 运行Stable Diffusion WebUI
配置:Ubuntu 22.04 LTS,48U+32G , Nvidia Tesla P40
![](https://blog.tutupost.cn/wp-content/uploads/2023/10/屏幕截图-2023-10-11-153926-300x257.png)
lspci
03:00.0 3D controller: NVIDIA Corporation GP102GL [Tesla P40] (rev a1)
系统安装
- 最小化安装系统 with SSH
- sudo apt install build-essential
显卡驱动
- 先禁用掉系统安装时候自带的驱动,再安装P40的驱动
- sudo nano /etc/modprobe.d/blacklist-nouveau.conf, 添加
- blacklist nouveau
- options nouveau modeset=0
- sudo update-initramfs -u
- sudo reboot
- sudo ./NVIDIA-Linux-x86_64-515.105.01.run
- 安装cuDNN sudo dpkg -i cudnn-local-repo-ubuntu2204-8.9.4.25_1.0-1_amd64.deb
- sudo cp /var/cudnn-local-repo-ubuntu2204-8.9.4.25/cudnn-local-72322D7F-keyring.gpg /usr/share/keyrings/
- 再次安装cuDNN sudo dpkg -i cudnn-local-repo-ubuntu2204-8.9.4.25_1.0-1_amd64.deb
安装SD需要的前置环境
- sh Miniconda3-py310_23.5.2-0-Linux-x86_64.sh
- apt-get install python3.10-venv #因为SD需要用venv自己建立环境,因此需要补充python venv 包依赖
- sudo apt-get -y install libtcmalloc-minimal4 #Google 内存优化
安装SD
- git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
- ./webui.sh
SD安装完之后
- source venv/bin/activate
- pip install -U xformers
- sudo apt install ffmpeg
- 调整启动文件参数 webui-user.sh
# Commandline arguments for webui.py, for example: export COMMANDLINE_ARGS="--medvram --opt-split-attention"
export COMMANDLINE_ARGS="--listen --xformers "
export XFORMERS_PACKAGE=xformers==0.0.22
启动正常
(base) ubuntu@02appai:~$ cd stable-diffusion-webui/
(base) ubuntu@02appai:~/stable-diffusion-webui$ ./webui.sh
################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################
################################################################
Running on ubuntu user
################################################################
################################################################
Repo already cloned, using it as install directory
################################################################
################################################################
Create and activate python venv
################################################################
################################################################
Launching launch.py...
################################################################
Using TCMalloc: libtcmalloc_minimal.so.4
Python 3.10.6 (main, Oct 24 2022, 16:07:47) [GCC 11.2.0]
Version: v1.6.0
Commit hash: 5ef669de080814067961f28357256e8fe27544f4
Launching Web UI with arguments: --listen --xformers
Loading weights [6ce0161689] from /home/ubuntu/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors
Running on local URL: http://0.0.0.0:7860
To create a public link, set `share=True` in `launch()`.
Startup time: 68.7s (prepare environment: 30.1s, import torch: 12.8s, import gradio: 6.7s, setup paths: 9.5s, initialize shared: 0.9s, other imports: 5.1s, setup codeformer: 0.5s, load scripts: 0.9s, reload hypernetworks: 0.1s, create ui: 1.3s, gradio launch: 1.0s).
Creating model from config: /home/ubuntu/stable-diffusion-webui/configs/v1-inference.yaml
Applying attention optimization: xformers... done.
Model loaded in 73.8s (load weights from disk: 7.3s, create model: 1.1s, apply weights to model: 61.9s, apply half(): 0.2s, load textual inversion embeddings: 0.4s, calculate empty prompt: 2.9s).
最新评论
真不错