Skip to content

Runpod Guide

ffxvs edited this page Jul 27, 2024 · 8 revisions

This guide is for sd_webui_runpod.ipynb and sd_webui_forge_runpod.ipynb.

Because Jupyterlab doesn't have an input form like Google Colab, to change value of the options we have to change them directly in the code. It looks complicated, but it's not difficult at all.

🔴 DO NOT CHANGE ANY CODE BELOW THE ####### LINE

Table of Contents

  1. Requirements
    1.1. Variables and Functions
    1.2. Dependencies
    1.3. Shared Storage
  2. Setup Web UI
    2.1. Web UI
    2.2. Extensions
  3. Launch Web UI

Tips

  • Use the triangle arrow button to the left of the cell title to show/hide the cell contents to make scrolling easier.
  • Use the Table of Contents in the left sidebar for easier navigation.
  • You can open the links provided for each model name, extension, or other resources to see more details.
  • Run cell with the play button in the toolbar or hotkey shift+enter.
  • Wait for the cell to finish executing until the Completed message in green box appears in the output.
  • Clear the output with Clear Cell Outputs or Clear Outputs of All Cells in the right click context menu.
  • To download images you generated, right click on the outputs folder then click Download as an Archive.
  • If you are running a newly created Pod, run each necessary cell one by one.
  • If you are running an existing Pod or an idle Pod, the cells that must be run are :
    • 1.1. Function and Data
    • 1.2. Dependencies
    • 5. Launch Webui

Change the value of options

When using this notebook you will often encounter several types of options whose values can be changed.

  • option = boolean[*]
    Boolean contains two values, False and True
    False : boolean[0]
    True : boolean[1]
    Example :
darkTheme = boolean[1]

  • option = []
    Fill the bracket with strings enclosed in single quotation marks ', separated by commas ,
    Example :
otherExtensions = [  
     'https://github.com/Bing-su/adetailer',  
     'https://github.com/continue-revolution/sd-webui-animatediff'  
]  

  • option = ''
    Write string inside the single quotation marks ' '
    Example :
ngrokToken = 'your_ngrok_token'

Check for Updates

Check the latest version of the notebook. If a new version is found, a download button will appear. Check the workspace directory to see the download.


1. Requirements

1.1. Variables and Functions

Contains functions and data needed to run all cells in the notebook. Required every time you want to use the notebook or more precisely when the kernel starts running. If the kernel is shut down or restarted, then this cell must be executed again.

  • civitaiToken
    Required to download models that require login. Sign up to civitai.com, then go to account settings. Scroll to API Keys then add API key. Save your API key somewhere. Copy it to civitaiToken. Example :
civitaiToken = 'your_civitai_api_key'

1.2. Dependencies

Install required dependencies. Most dependencies have been installed inside the docker image, especially large dependencies like Pytorch. So, this shouldn't take long. Required every time you start the Pod.

1.3. Shared Storage

Create a shared storage directory. Shared storage stores models, embeddings, loRA, upscaler, VAE, outputs and configs. There is a feature called Network Volume, which is persistent storage that can be used on multiple Pods but cannot be used across Data Center. You still need to run this cell even though you are not using Network Volume. Required every time you create a new Pod.


2. Setup Web UI

2.1 Web UI

Install/Update Stable Diffusion Web UI/Forge. Required every time you create a new Pod. If you have an idle Pod, you don't need to run this cell again. Run it again to update the Web UI if there is a new version.

2.2. Extensions

You can choose any extensions you want to install before launching webui. There are pre-installed extensions that will be installed automatically and several popular extensions that may be useful for you. To install an extension, just change the extension value from boolean[0] to boolean[1]. As for SD Web UI Forge, since that is a fork of Stable Diffusion Web UI, some extensions might not work properly. If you find any extension error, please report it to me on github.

  • updateExts
    If you want to update built-in and selected extensions, change this option to boolean[1].

  • Install Extensions from URLs
    You can install other extensions yourself by copying the github repository URL into bracket of otherExtensions.
    Example :

otherExtensions = ['https://github.com/Bing-su/adetailer']
# or
otherExtensions = [
    'https://github.com/Bing-su/adetailer',
    'https://github.com/continue-revolution/sd-webui-animatediff'
]

3. Launch Web UI

  • darkTheme : Enable dark theme by default
  • Authentication
    When you launch a Web UI on the internet, anyone can access it freely which can be harmful. It's recommended to enable authentication for security reasons.
username = 'your_username'
password = 'your_password'
  • Optimization :
    • xformers is already installed.
    • For opt-sdp-attention and opt-sdp-no-mem-attention set directly from webui settings.
  • ngrok (optional)
    Proxy for stable connection and static url. One of the advantages of having a static url is that you can use State extensions properly because the parameters are stored in the subdomain that do not change. Register at ngrok.com. Open your dashboard, copy your authtoken to ngrokToken. Create a free ngrok domain then copy it into ngrokDomain without https://. Example :
ngrokToken = 'your_ngrok_token'
ngrokDomain = 'free-sub-domain.ngrok.free.app'
  • CORS (optional)
    To bypass CORS policy. Write URLs with https:// inside cors. Separate them with commas.
    Example :
cors = 'https://huchenlei.github.io,https://ffxvs.github.io'