Cobra Forum

Plesk Panel => Web Application => Topic started by: mahesh on Feb 15, 2024, 06:40 AM

Title: Create a Stable Diffusion Web UI with a Vultr Cloud GPU
Post by: mahesh on Feb 15, 2024, 06:40 AM

(https://pix.cobrasoft.org/images/2024/02/15/header-8.png)Introduction
Stable Diffusion is a deep learning model that can generate detailed images based on input text descriptions. It can also be used to enhance an existing image or generate a new one based on another, guided by a text description prompt. This guide explains how to create a Stable Diffusion web UI on a Vultr Cloud GPU running on Ubuntu 22.04 using this Stable Diffusion web UI repository on GitHub.

Prerequisites
Security Considerations
This guide creates a web UI for Stable Diffusion, but does not provide any protection from unwanted users or attacks. We strongly recommend that you protect your installation with a proxy or firewall, like these options:

Create a Stable Diffusion Web UI
1.Install Git Large File Storage (LFS) to clone the Stable Diffusion model.

$ sudo apt install git-lfs
2.Initialize Git Large File Storage (LFS).

$ git lfs install
3.Clone the Stable Diffusion repository. Enter your Hugging Face account credentials twice when prompted.

$ git clone https://huggingface.co/CompVis/stable-diffusion-v-1-4-original
You only need the weights or the sd-v1-4.ckpt checkpoint file from this repository.

4.Wait for the cloning to finish.

5.Clone the Stable Diffusion Web UI Repository.

$ git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
6.Copy the sd-v1-4.ckpt checkpoint file from the Stable Diffusion directory to the stable-diffusion-webui/models/Stable-diffusion/ Web UI directory and rename it as model.ckpt

$ cp ~/stable-diffusion-v-1-4-original/sd-v1-4.ckpt ~/stable-diffusion-webui/models/Stable-diffusion/model.ckpt
7.Remove the Stable Diffusion folder you have cloned because you only need the sd-v1-4.ckpt file.

$ rm -rf ~/stable-diffusion-v-1-4-original
8.Install the FastAPI framework using pip.

$ pip3 install fastapi
9.The Stable Diffusion Web UI runs on port 7860 by default, so you must enable port 7860 on your firewall.

$ sudo ufw allow 7860
Run the Stable Diffusion Web UI with Tmux
When you run your Stable Diffusion Web UI on a normal SSH session, the Web UI's process closes when you exit the SSH session. To continuously run your Web UI even when you leave the SSH session, use tmux, a terminal multiplexer.

1.To create a Tmux session, run:

$ tmux new -s StableDiffusion
You may change StableDiffusion with any session name you prefer. Please see How to Install and Use Tmux for more information about Tmux.

2.Change the directory to stable-diffusion-webui.

$ cd ~/stable-diffusion-webui
3.Launch the Stable Diffusion Web UI by running launch.py using python.

$ python3 launch.py --listen
The --listen argument makes your Web UI listen to network connections, not just on localhost. Please see Command Line Arguments and Settings for more information.

4.Wait until your server launches.

5.Detach from the Tmux session by pressing CTRL + B then D.

Test the Stable Diffusion Web UI
Example - Stable Diffusion Web UI
(https://pix.cobrasoft.org/images/2024/02/15/7pSSz4P.jpg)
You have successfully created a Stable Diffusion Web UI on a Vultr Cloud GPU.