This guide describes how to use the SD35_LoRA_Colab.ipynb notebook to fine-tune Stable Diffusion 3.5 with LoRA adapters on Google Colab GPUs.
- Fork
seochan99/stable-diffusion-3.5-text2image-lorato your GitHub account. - Clone your fork:
git clone https://github.com/<your-username>/stable-diffusion-3.5-text2image-lora.git cd stable-diffusion-3.5-text2image-lora
- Copy
SD35_LoRA_Colab.ipynbinto the repository root (already provided in this fork). - Commit and push the notebook:
git add SD35_LoRA_Colab.ipynb docs/COLAB_FINETUNING.md git commit -m "Add Colab workflow for SD3.5 LoRA fine-tuning" git push origin main
- Navigate to your fork on GitHub.
- Open
SD35_LoRA_Colab.ipynband click the Open in Colab badge (or change the URL tohttps://colab.research.google.com/github/<user>/stable-diffusion-3.5-text2image-lora/blob/main/SD35_LoRA_Colab.ipynb). - Switch the runtime to GPU (
Runtime > Change runtime type > GPU).
- Environment check – verify GPU with
!nvidia-smi. - Install dependencies – install PyTorch (CUDA 12.1 build), Diffusers, Transformers, PEFT, etc.
- Hugging Face login – run the
login()cell and paste a token withreadscope.- Ensure you have accepted the license for
stabilityai/stable-diffusion-3.5-mediumwith the same account.
- Ensure you have accepted the license for
- Clone the repo – clones your fork into
/content/stable-diffusion-3.5-text2image-loraand sets it as the working directory. - (Optional) Mount Google Drive if your dataset or outputs live there.
- Dataset setup – update the paths in the cell defining
DATA_ROOTandOUTPUT_DIR.- Upload your pre-captioned dataset (e.g.,
prepared_dataset) into the Colab runtime or Drive. - Run the sanity-check cell to ensure
metadata.jsonland images are present.
- Upload your pre-captioned dataset (e.g.,
- Configure training – adjust
training_configandflag_argsas needed:train_data_dirshould point to your dataset directory inside Colab.- Prefer
mixed_precision = "fp16"on T4/L4 GPUs; leave as"bf16"only when using A100/V100/H100. - Enable
train_text_encoderonly if VRAM allows.
- Launch training – set
START_TRAINING = Trueand run the cell. Logs stream in-line.- Checkpoints and LoRA weights land in
OUTPUT_DIR. - Use TensorBoard cell after
logs/exists if desired.
- Checkpoints and LoRA weights land in
- To resume, set
training_config["resume_from_checkpoint"] = "latest"or to a specific checkpoint directory. - Reduce VRAM pressure via
train_batch_size = 1, highergradient_accumulation_steps, smallerrank, or training at512resolution initially.
- Execute the inference cell at the bottom of the notebook.
- Set
base_model,lora_dir, and prompts to match your experiment. - The generated sample is saved to
<OUTPUT_DIR>/sample_inference.png.
- Zip the final LoRA directory or push it to the Hugging Face Hub via
StableDiffusion3Pipeline.save_lora_weightsresults. - Commit updated configs or datasets (excluding large binary files) to a new branch and open a PR, if desired.
This workflow mirrors the training script in the repository while adding Colab-friendly setup, dataset verification, automated command construction, and inference validation.