Stable Diffusion on Genesis Cloud

Stable Diffusion on Genesis Cloud

Stable Diffusion, a latent text-to-image diffusion model, is on everyone’s lips. It is able to generate stunning pictures (like the title image of this post) of almost everything you can imagine from just few words (the “prompt”).

This blog post is a step-by-step guide that, when followed through, will end with your own personal Stable Diffusion web interface running on Genesis Cloud.

Prerequisites

To follow along with this tutorial, you will need

Step-by-Step Guide

Instance Creation

Before we get to the installation of any software we need to spin up an instance on Genesis Cloud:

Software Installation & Configuration

Unless noted otherwise, all the following steps are to be executed via SSH on your instance.

The process of connecting via SSH to your instance differs depending on what SSH client you use. Users of Putty on Windows can find a detailed guide at here and users of the command line SSH client on Linux or macOS can check out this.

For the rest of this guide we assume that you are connecting from a Linux system.

Update the System

Make sure that the whole system is up to date.

You might be able to skip over this step to save some time but, in turn, might miss out on important security and stability fixes. We recommend that you always keep all software on your instance up to date to avoid issues further down the line.

Install Python 3.10.6

While the Python ecosystem is excellent in that you will find tools and libraries for almost everything, it is, at the same time, a complex beast to tame. To avoid compatibility issues later on, we will install the exact Python version recommended by the Stable Diffusion WebUI authors. Unfortunately, that exact version is not readily available via the Ubuntu software repositories, so we will have to build it ourselves.

Download the Stable Diffusion Model

We will download the Stable Diffusion model using the BitTorrent protocol. The advantage of this over an HTTP download is that the network traffic is spread over multiple parties, and we do not have a single point of failure in the form of the originating web server.

Installing the Stable Diffusion WebUI

As of the time of writing this guide, several alternative web UIs for Stable Diffusion are publicly available. We experimented with most of them and feel that the version from GitHub user AUTOMATIC1111 is the most polished one at this time and therefore it is the one we recommend.

Output generated when running the webui.sh script

Accessing the WebUI

On Genesis Cloud your instances are, by default, protected by our firewall. This protection does not allow direct access to the port used by the WebUI from just anyone on the internet.

You can either update your network security groups to change that (check out our guide titled “How to create Security Groups to control your instance network traffic” for details) or you can utilize the SSH port forwarding functionality.

We strongly recommend that you access the WebUI employing SSH port forwarding as the WebUI was not developed with security considerations for public hosting in mind.

Linux and macOS users

You can use the port forwarding feature built into your SSH client to access the WebUI listening on port 7860 of the server. Disconnect your current session (you can terminate the running WebUI from the last step by pressing CTRL+C in your existing SSH session), and append -L 127.0.0.1:7860:127.0.0.1:7860 to the SSH command line you used before. It should like similar to this:

ssh ubuntu@<IPv4 address of your instance> -L 127.0.0.1:7860:127.0.0.1:7860

Once you are reconnected this will forward your local port 7860 to 7860 on the server’s loopback interface. Restart the WebUI (cd stable-diffusion-webui; bash webui.sh) and once you see Running on local URL: http://127.0.0.1:7860 you can open it in your browser at http://127.0.0.1:7860/.

Final Step: Testing

Learning how to create a prompt that generates great images can take a while. Something which works surprisingly reliable is corgis in data center hallways 🐶 😂: Screenshot of the Stable Diffusion WebUI showing a generated picutre of a cute Corgi in a datacenter

Keep accelerating 🚀

The Genesis Cloud team

Never miss out again on Genesis Cloud news and our special deals: follow us on Twitter, LinkedIn, or Reddit.

Sign up for an account with Genesis Cloud here and benefit from $15 in free credits. If you want to find out more, please write to [email protected].