Stable Diffusion

Stable Diffusion is very powerful and you can run it on Vast instances
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 make an easy to use web interface. The models themselves can be downloaded from Hugging Face. This guide follows one of the available repos in order to get the webui working.

Setup your Vast account

The first thing to do if you are new to Vast is to go 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 will also need to setup SSH keys so you can login to the instance. The setup is different if you are on Windows vs macOS/Linux. Follow these instructions.

Automatic111 fork - by Ideefixze

The typical Automatic111 webui interface doesn't work out of the box on Vast. As of 11/17/22 there is a fork of the repo that is maintained located here.
This section will walk you through how to setup stable diffusion to work using that repo.

Setup the docker config options

Click on the EDIT IMAGE & CONFIG button from the create page. Select the Pytorch/Pytorch image and click on it again to open up the options. Select the SSH launch mode and click the direct option.
Under the run commands, add this:
-p 7860:7860
It should look like this:
Options for Stable Diffusion
Then under the on-start script, copy and paste in this code:
apt update -y;
apt upgrade -y;
apt install -y libgl1 transmission-cli screen python3-venv;
git clone https://github.com/Ideefixze/stable-diffusion-webui-vast-ai;
cd stable-diffusion-webui-vast-ai;
conda create -n "stable-diff" python=3.10.4 -y;
conda init bash;
bash;
conda activate stable-diff;
Afterwards it should look like this:
Move the storage slider over to at least 30 GB. Note that you cannot change how much disk space your instance has once it is created so it is important to allocate enough space to start. The storage slider is always available in the upper left of the create interface.
Click the Select & Save button to save the settings.

Pick a GPU offer

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. We recommend an A6000, A40 or A100 if you want to max the Stable Diffusion settings.
If available, it is also best to pick a host with the datacenter label, as those machines are more reliable. Click the blue RENT button to spin up the instance.

Download the CKPT models and start the webui

You will need to download the CKPT models from Hugging Face onto the instance in order for the webui to run. The simplest model to download is Waifu Diffusion. Navigate to the right folder and download it from Hugging Face.
cd /workspace/stable-diffusion-webui-vast-ai/models/Stable-diffusion
wget https://huggingface.co/hakurei/waifu-diffusion-v1-3/resolve/main/wd-v1-3-full.ckpt
The latest version of Stable Diffusion is version 1.5. You will need to accept licensing terms before you can download the model.
Go to the Hugging Face repo, setup an account with Hugging Face (if you don't already have one) and agree to the TOS for Stable Diffusion v1.5 here. Then go and setup a read only token here.
Change hf_userid to your Hugging Face userid and replace hf_read_token with your token.
wget --user=hf_userid --password=hf_read_token https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned.ckpt
You now have 2 models that will be accessible from the webui. You can add other CKPT files in the models/Stable-Difffusion folder.

Run webui.sh and connect

To run the webui script:
cd /workspace/stable-diffusion-webui-vast-ai
./webui.sh
The script will download and install a few things. It should take 2-5 minutes to start. Once it is running you do not need to do anything else. Just leave the SSH session running. It will print out text saying it is running locally on port 7860 similar to this:
Loading weights [e1de58a9] from /workspace/stable-diffusion-webui-vast-ai/models/Stable-diffusion/wd-v1-3-full.ckpt
Global Step: 683410
Applying cross attention optimization (Doggettx).
Model loaded.
Loaded a total of 0 textual inversion embeddings.
Embeddings:
Running on local URL: http://0.0.0.0:7860
To load the web interface, go to the instances page and click on the IP address bar to pull up the IP&Port Info. The IP address and external port that is mapped to 7860 is displayed. Copy and paste that into your browser to load the interface.
And there you go! You can select the different models in the upper left.

Done? Destroy the instance

After you generate your artwork and are done with the instance, you have a few options. If you STOP the instance using the stop button, you will no longer pay the hourly GPU charges. However you will still incur storage charges because the data is still stored on the host machine. When you hit the START button to restart the instance, you are also not guaranteed that you can rent the GPU as someone else might have rented it while it was stopped. We don't recomend that you stop an instance once done with you.
To incur no other charges you have to DESTROY the instance using the trash can icon. We recommend you destroy instances so as not to incur storage charges while you are not using the system.
The next time you go to start up Stable Diffusion, your configuration options are all saved. You will have to re-download the CKPT models and re-run the webui.sh script.
Have fun!