This lesson is being piloted (Beta version)

Stable Diffusion on SMU HPC

How to use SMU M3 Virtual Dekstop

Overview

Teaching: 5 min min
Exercises: 0 min
Questions
  • How to use SMU M3 Virtual Dekstop?

Objectives

1. SMU ManeFrame 3 Virtual Desktop

image

image

Key Points

  • M3 Virtual Desktop


Creating your own conda environment

Overview

Teaching: 5 min min
Exercises: 0 min
Questions
  • How to create conda environment with GPU supported library

Objectives

2. Creating the conda environment

Now it the time to create your own conda environment so that you can get the GPU supported library working for you. Follow these steps:

Load neccesary modules with GPU supported library

$ module load spack conda cuda-11.8.0-gcc-11.2.0/cudnn/8.7.0.84-11.8-aydlfs6 cuda/gcc-11.2.0/cuda/11.8.0-vnha6cm

Create conda environment and name it sd (for stable diffusion), save it on your desktop:

$ conda create --prefix ~/sd python=3.10.13 pip –y

activate it once you done creating the environment:

$ conda activate ~/sd

Key Points

  • Conda environment, GPU, cuda


Install Automatic1111 to M3

Overview

Teaching: 5 min min
Exercises: 0 min
Questions
  • How to install Automatic1111 and use the UI?

Objectives

3. Install Automatic1111 onto M3 with UI and GPU supported

One of the most popular UI for Stable Diffusion is Automatic1111 which is an open source project and can be found from their github: https://github.com/AUTOMATIC1111/stable-diffusion-webui

The following steps instruct you to install it on SMU M3, after creating the conda env and activate it in Step 1:

$ conda activate ~/sd

Download the model (either by gitclone or download zip file from their repo):

I encourage you to download it to your $WORK folder since you have plenty of space (avoid the limitted $HOME storage):

$ cd $WORK
$ git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

Next download one sample checkpoint (pre-trained model) for your usage.

I suggest to download one from HuggingFace, runwayml

$ cd $WORK/stable-diffusion-webui/models/Stable-diffusion
$ wget https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly.ckpt

You can download as many checkpoint in the format of ckpt or safetensors to the models folder for your usage.

Run the executable: webui.sh

$ cd $WORK/stable-diffusion-webui
$ ./webui.sh

If you see the http link appear as in the screenshot below, copy it and paste to the Chrome browser from the Virtual Desktop:

image

image

Want to have shortcut?

Put the following line to your bashrc file:

$ echo alias sd1="'module load spack conda && module load cuda-11.8.0-gcc-11.2.0/cudnn/8.7.0.84-11.8-aydlfs6 cuda/gcc-11.2.0/cuda/11.8.0-vnha6cm && conda activate ~/sd && cd $WORK/stable-diffusion-webui && ./webui.sh'" >> ~/.bashrc
$ source ~/.bashrc
$ sd1

Key Points

  • Automatic1111, GUI


Installing ComfyUI to M3

Overview

Teaching: 20 min
Exercises: 0 min
Questions
  • How to use install ComfyUI?

Objectives
  • Install ComfyUI

4. Install ComfyUI to M3

Alternative to Automatic1111, is ComfyUI which is an open source project and can be found from their github: https://github.com/AUTOMATIC1111/stable-diffusion-webui

The following steps instruct you to install it on SMU M3, after creating the conda env and activate it in Step 1:

$ conda activate ~/sd

Download the model (either by gitclone or download zip file from their repo):

I encourage you to download it to your $WORK folder since you have plenty of space (avoid the limitted $HOME storage):

$ cd $WORK
$ git clone https://github.com/comfyanonymous/ComfyUI.git
$ cd ComfyUI/custom_nodes
$ git clone https://github.com/ltdrdata/ComfyUI-Manager.git

Run the GUI

$ cd $WORK/ComfyUI
$ pip install -r requirement.txt
$ python main.py

If you see the http link appear as in the screenshot below, copy it and paste to the Chrome browser from the Virtual Desktop:

image

image

Key Points

  • ComfyUI


Install InvokeAI to M3

Overview

Teaching: 20 min
Exercises: 0 min
Questions
  • How to install InvokeAI to M3

Objectives
  • Install InvokeAI

5. Install InvokeAI to M3

Alternative to Automatic1111 and ComfyUI, InvokeAI is open source package: https://github.com/invoke-ai/InvokeAI

The following steps instruct you to install it on SMU M3, after creating the conda env and activate it in Step 1:

$ conda activate ~/sd

Download the latest model (either by gitclone or download zip file from their repo):

https://github.com/invoke-ai/InvokeAI/releases/tag/3.7.0

I encourage you to download it to your $WORK folder since you have plenty of space (avoid the limitted $HOME storage):

$ cd $WORK
$ wget https://github.com/invoke-ai/InvokeAI/releases/download/3.7.0/InvokeAI-installer-v3.7.0.zip

Unzip and Run the installer

$ cd $WORK
$ unzip InvokeAI-installer-v3.7.0.zip
$ cd InvokeAI-Installer
$ ./install.sh

Follow the prompt, when asked to select the install destination, change it to

/lustre/work/client/users/**$your_username**/invokeai

Once done installation, you can run the GUI:

$ cd $WORK/invokeai
$ ./invoke.sh

Select 1 to “Generate images with a browser-based interface”

If you see the http link appear as in the screenshot below, copy it and paste to the Chrome browser from the Virtual Desktop:

image

image

Run the sample:

image

Key Points

  • InvokeAI


Install Fooocus to M3

Overview

Teaching: 15 min min
Exercises: 0 min
Questions
  • Install Fooocus to M3

Objectives

5. Install Fooocus to M3

Foocus is open source package: https://github.com/invoke-ai/InvokeAI

The following steps instruct you to install it on SMU M3, after creating the conda env and activate it in Step 1:

$ conda activate ~/sd

Download the latest model (either by gitclone or download zip file from their repo):

I encourage you to download it to your $WORK folder since you have plenty of space (avoid the limitted $HOME storage):

$ cd $WORK
$ git clone https://github.com/lllyasviel/Fooocus.git

Run the installer

$ cd $WORK/Fooocus
$ python launch.py

If you see the http link appear as in the screenshot below, copy it and paste to the Chrome browser from the Virtual Desktop: image

image

And run a sample:

image

Key Points

  • Foocus


Port-Forwarding your UI with SuperPOD

Overview

Teaching: 5 min min
Exercises: 0 min
Questions
  • How to Port-Forwarding with SuperPOD

Objectives

7. Using SuperPOD

The method of using conda environment in SuperPOD is similar to ManeFrame 3. These are the steps:

1. Setup your own conda environment in SuperPOD with cuda library supported (refer to my SuperPOD 101 lecture notes)

2. Install the Stable Diffusion UI model onto your SuperPOD account (Automatic1111,ComfyUI, InvokeAI, Fooocus)

3. Notice the following ports are used for each model:

$ ssh -C -D 8000 tuev@superpod.smu.edu
$ srun -N 1 -G 1 -c 10 --mem=64gb --time=12:00:00 --pty $SHELL

Assume you are given a node name: bcm-dgxa100-0001

$ module load conda gcc cuda cudnn
$ conda activate ~/sd
$ cd $WORK/stable-diffusion-webui
$ jupyter lab &
$ ./webui.sh & # Note this is changed for each model (ComfyUI, InvokeAI, Fooocus)

Leave this terminal 1 going on and open another terminal

4.2. Terminal 2

Now you will need to ssh to the SuperPOD with the Dynamic and Static port and the requested node bcm-dgxa100-0001.

$ ssh -J tuev@superpod.smu.edu tuev@bcm-dgxa100-0001 -L 8000:localhost:8000 -L 7860:localhost:7860

Enter password twice with DUO, then you will be logged in a node

4.3. Open your browser that you have already setup the forwarding port to localhost with port 8000

Type in the address 127.0.0.1:7860, you will be able to run Automatic1111.

Do the same step for other UI model.

Key Points

  • Conda environment, GPU, cuda