> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cudocompute.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Stable Diffusion

> AI image generation in the cloud using NVIDIA GPUs on CUDO Compute.

Stable Diffusion is a latent text-to-image diffusion model specializing in the generation of photo-realistic
images based on textual inputs. It offers users the ability to autonomously create striking visual art within seconds.
This model represents a significant advancement in image generation, particularly in terms of enhanced image
composition and face generation, resulting in visually impressive and highly realistic output.

With CUDO Compute you can deploy Stable Diffusion to the latest NVIDIA Ampere Architecture GPUs.
Prebuilt images with NVIDIA drivers are ready to deploy.

## Prerequisites

* Create a project and [add an SSH key](/docs/tutorials/how-to-generate-ssh-keys)
* Choose a virtual machine with an NVIDIA GPU and remember to add plenty of storage
* Use the **Ubuntu 22.04 + NVIDIA drivers + Docker** image (in CLI tool type `-image ubuntu-nvidia-docker`)

The main reason to select a higher VRAM is if you require larger image sizes

## Install easy diffusion

SSH into your virtual machine and run the following commands

```shell theme={null}
apt install zip -y
```

```shell theme={null}
wget https://github.com/cmdr2/stable-diffusion-ui/releases/latest/download/Easy-Diffusion-Linux.zip
```

```shell theme={null}
unzip Easy-Diffusion-Linux.zip
```

```shell theme={null}
cd easy-diffusion
```

### Start easy diffusion

Run easy diffusion and enable web remote access

```shell theme={null}
echo -e "net:\n    listen_port: 9001\n    listen_to_network: true" > config.yaml
```

```shell theme={null}
./start.sh
```

Wait a few minutes and go to `http://<your-vm-ip>:9001` in your web browser

Stop easy diffusion and install xformers, then restart

### Install xformers

```shell theme={null}
./developer_console.sh
```

```shell theme={null}
python -m pip install --upgrade torch==2.0.1+cu118 torchvision==0.15.2+cu118 xformers==0.0.22 --extra-index-url https://download.pytorch.org/whl/cu118
```

### Extra models

Optionally if you want to add another model over the standard they can be found here:

* [https://huggingface.co/stabilityai/stable-diffusion-2-1](https://huggingface.co/stabilityai/stable-diffusion-2-1)
* [https://huggingface.co/stabilityai/stable-diffusion-2-1-base](https://huggingface.co/stabilityai/stable-diffusion-2-1-base)
* [https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0)

An example of how to add them:

```shell theme={null}
cd ~/stable-diffusion/models/stable-diffusion
```

```shell theme={null}
wget https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/main/v2-1_768-ema-pruned.ckpt
```

```shell theme={null}
wget https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors
```

```shell theme={null}
cd ../.. && ./start.sh
```
