Using Stable Diffusion on Vast.ai
Stable Diffusion is a deep learning, text-to-image model that has been publicly released. It uses a variant of the diffusion model called latent diffusion. There are a few popular Open Source repos that create an easy to use web interface for typing in the prompts, managing the settings and seeing the images.
This guide will use the webui Github repo maintained by Automatic111 here. The docker image used comes pre-loaded with Stable Diffusion v2.1, and it is possible to upload other models once you have the instance up and running. The recommend template will also setup Jupyter so you can use a web browser to download and upload files to the instance.
For all questions or issues with the web GUI, the project has a readme with links.
The first thing to do if you are new to Vast is to create an account. Then head to the Billing tab and add credits. This is pretty self-explanatory. Vast uses Stripe to processes credit card payments and also accepts major cryptocurrencies through Crypto.com. $20 should be enough to start. You pre-buy credits on Vast and then spend them down.
Click on the Change template button from the create page. Then click on the edit button on the Stable Diffusion template. We will need to set a username and password, so it is very important that we edit our template to set a username and password first.
3) Set your username and password
To set your username and password, go to the beginning of the Docker Options and add the arguments
as shown below.
You can also add the variables one by one in the env input:
Stable Diffusion can only run on a 1X GPU so select 1X from the filter menu on the top nav. This will then update the interface to show 1X GPU offers. Note that some Stable Diffusion models require large amounts of GPU VRAM. For max settings, you want more GPU RAM. Use the GPU RAM slider in the interface to find offers with over 20GB. The availability of specific GPU models can vary over time on the platform. I utilized an RTX 4090, which provided excellent results. However, I recommend reviewing the current GPU options on Vast.ai to choose a model that best fits your performance requirements and budget.
If available, it is also best to pick a host with the datacenter label, as those machines are more reliable. You can filter through different options using the search filter on the left. (see below)
Click the blue RENT button to spin up the instance. You can then watch progress from the instance tab.
5) Connect and start making art
The instance can take 3–5 minutes to start. Once it is ready a blue connect button will appear. Click on that to open the web gui.
Once you click connect you will see the page below.
From here click into the direct link. And there you go! Please read the Automatic111 documentation for how the web GUI works.
Next create an image, make sure all the fields below are selected.
From there click the Txt2img tab, then type a negative and positive prompt. See below. Then click generate to create your art.
Next we will create & img2img generation, which takes your original image and creates new art based off of it.
Click the image2image tab, upload the image you want by either dragging it over, or clicking on the upload button, add a positive and negative prompt.
Next click generate. I ended up generating a futuristic cat. (See below)
There are buttons to save, download, and also zip the art .
I wanted to give some credits to Karthik and the whole team at Vast.AI for this blog post , happy computing!