Skip to content

Instantly share code, notes, and snippets.

@DaWe35
Created March 3, 2024 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaWe35/09bd74357c590ae70a15edee9014b803 to your computer and use it in GitHub Desktop.
Save DaWe35/09bd74357c590ae70a15edee9014b803 to your computer and use it in GitHub Desktop.
Stable diffusion setup on Google Cloud Instances

Install

  • Get a Gcloud instance with GPU and Debian 12 (spot instances are cheaper but can be interrupted)

  • Add a VPC firewall rule to enable 7860 port. Add this rule to the Compute Instance (edit -> networking)

  • Open a screen: screen. It is always a good idea to use screen, because if the connection interrupts, it will preserve the opened process. Next time when you connect, type screen -r to reopen or screen -rd to force reopen after an interruption.

  • Install and verify GPU driver:

curl https://raw.githubusercontent.com/GoogleCloudPlatform/compute-gpu-installation/main/linux/install_gpu_driver.py --output install_gpu_driver.py
sudo python3 install_gpu_driver.py
sudo nvidia-smi
  • Connect to the VM by clicking the SSH button on the instance, and enter Y when it asks to install the GPU driver.
sudo apt update && apt upgrade
sudo apt install wget git python3-venv
sudo apt install python3-pip
sudo apt install libsm6 libxext6
  • Navigato to a folder install the WebUI (I'll use this auto install script for now):
bash <(wget -qO- https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh)
  • Exit when you see Model loaded in ... and restart with
bash webui.sh --listen

The --listen argument will make the UI publicly available on the internet.

Open ip:7860

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment