This set of instructions will get you up and running the latest and greatest Stable Diffusion WebUI on HiPerGator.
Stable Diffusion Web UI by AUTOMATIC1111To run Web UI on HiPerGator is pretty straight forward, but it's a sort of hybrid between running something "local" and running it "remote." We want to use our wonderful access to an array of NVIDIA A100 GPUs on HiPerGator, but we need to use the graphical interface afforded Web UI. Here's what to do:
First, we'll install everything, then quit and relaunch it with a SLURM batch script using the same technique as running a Jupyter Notebook locally. Once installed, in day-to-day use, you'll use the SLURM batch script to launch Web UI.
Move to your working directory on "blue." Substitute the group name (art4612, art4630, cota-dept, etc.) for <groupname> as well as your username for <gatorlink> in the command below:
Code: Select all
cd /blue/<groupname>/share/<gatorlink>/
Code: Select all
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
Code: Select all
cd stable-diffusion-webui
nano webui-user.sh
Next, we need to modify the TORCH_COMMAND to install specific versions in order to work with HiPerGator. The appropriate versions will change with time, but as of 01.2023, below is correct:
Code: Select all
export TORCH_COMMAND="pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118"
Grab a GPU. Modify this based on how long you want and be sure to substitute the appropriate HiPerGator groupname (art4612, art4630, cota-dept, etc.) for your job:
Code: Select all
srun -p gpu --nodes=1 --gpus=a100:1 --time=2:00:00 --mem=16gb --ntasks=1 --cpus-per-task=1 --pty -u -A <groupname> -q <groupname> bash -i
[These are the best versions as of Fall 2023]
Code: Select all
module load cuda/11.4.3
module load gcc
module load git
module load python/3.10
module load ffmpeg/4.3.1
module save webui
Code: Select all
module r webui
Code: Select all
module list
Code: Select all
module spider ffmpeg
Code: Select all
cd models/Stable-diffusion
cp ../../../../models/Stable-diffusion/sd-v1-4.ckpt .
UPDATE: of course, you may want to get the latest model yourself or use a model I haven't provided. SDXL 1.0 was recently released. You would get that here:
https://huggingface.co/stabilityai/stab ... l-base-1.0
Navigate to your models directory, into the Stable-diffusion directory and run:
Code: Select all
wget https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors
Now we can proceed with installing the necessary dependencies and run webui.
Change directories from your current location (models/Stable-diffusion) to the root install directory (stable-diffusion-webui):
Code: Select all
cd ../../
Code: Select all
bash webui.sh
Okay, everything is installed. Let's get remote access to the application going. I have written a shell script that does that for us. It is adapted from the shell script that launches Jupyter Lab. We'll grab the SLURM batch script from my GitHub repository.
Move out of our current working directory (stable-diffusion-webui) and clone my "slurm_examples":
Code: Select all
cd ..
git clone https://github.com/jstenner/slurm_examples.git
By now, you should know how to edit SLURM batch scripts to customize them for your purposes (e.g. run time, commandline arguments, etc.). Move to your webui working directory and edit the batch script:
Code: Select all
cd stable-diffusion-webui
nano webui_sbatch.sh
Set the time you want the job to run. Set your gradio-auth USERNAME:PASSWD in the python command on the last line.
Save your changes: Ctrl + o, Enter, Ctrl + x.
Now LAUNCH:
Code: Select all
sbatch webui_sbatch.sh
Code: Select all
tail -f webui_<jobid>.out
Finally, copy/paste the "Local browser URI" into your web browser. It may not work immediately because the application is still loading the model and starting up. After a minute or two, refresh the page and the Gradio login dialog should appear and you're ready to login and get started!
Notice that as you render, you'll get feedback about what's happening in your main terminal window (the one with "tail" running). At first webui needs to download certain models and support files so it may be a bit slow. Once everything is available to you, it's very quick.
HAVE FUN!
To quit, type "Ctrl + c" in your shell tunnel terminal window to close that down.
Type "Ctrl + c" in your main terminal window to close "tail". Then type:
Code: Select all
squeuemine
Code: Select all
scancel <JOBID>
Code: Select all
exit
