ArtificialGuyBR

Home / Blog / Training LoRAs

SDXL LoRA Training: Colab vs Hosted Trainers

Compare free T4 GPUs on Colab vs Kaggle for SDXL LoRA training, understand session timeouts, and discover hosted trainer alternatives.

11 sources cited Training LoRAs

SDXL LoRA Training: Colab vs Hosted Trainers

TL;DR


For more on Kaggle notebook persistence, see Kaggle notebook chaining guide.

Colab vs. Kaggle: GPU Hardware and Quotas

TierGPU TypeVRAMSession Idle TimeoutMax Session LengthWeekly GPU Hours
Colab (free)Tesla T416 GB90 minutes12 hoursVaries (no fixed quota)
Colab ProTesla T416–40 GB90 minutes24 hoursUnlimited compute units
Kaggle (free)2× Tesla T416 GB each20 minutes12 hours30 hours / week

Both platforms ground users in NVIDIA T4 GPUs, but Kaggle's "T4 x2" accelerator provisions two physical T4 cards in a single container, giving you 29 GB RAM and the ability to run multi-GPU training. Colab's free tier provides a single T4. Neither platform guarantees specific GPU models—Colab's FAQ states "GPU types vary" depending on availability.

Phone verification required: Kaggle mandates phone number verification to unlock GPU access. Unverified accounts receive CPU-only sessions.


Session Timeouts and Persistence

Colab: Drive Mount Over File System

Colab’s runtime terminates after 90 minutes of inactivity, but your files survive through Google Drive. Mount your Drive at /content/drive/MyDrive/ and store checkpoints there:

from google.colab import drive
drive.mount('/content/drive')

The next session re-mounts the same path. This pattern works for any storage: LoRAs, training data, or model weights.

Kaggle: Working Directory vs. Temp Storage

Kaggle notebooks offer two storage zones:

Download large models to /kaggle/temp/models/ for space, but always copy final LoRAs to /kaggle/working/ before the session expires.

Chaining Notebooks for Continuity

Kaggle’s “chain notebooks” feature lets you attach any notebook’s /kaggle/working output as a dataset input. This is the only way to preserve large files across sessions. Save your LoRA checkpoint, then create a new notebook that imports it as data.


SDXL Training Settings for Limited VRAM

For detailed hyperparameter tuning, see SDXL training guide.

Why --full_fp16 Is Necessary

SDXL’s UNet has ~2.6 billion parameters. In fp32, weights alone need 10.4 GB. Add activations and AdamW optimizer states (8 bytes/param) and you exceed 16 GB VRAM.

--full_fp16 stores optimizer states in fp16 (2 bytes/param), cutting peak memory roughly in half. The Kohya trainer notebook enables this automatically for T4 sessions.

Caching Latents to Disk

The --cache_latents --cache_latents_to_disk flags precompute and store latent embeddings on disk instead of recomputing them each training step. The notebook notes this provides a “huge speed up.”

SettingEffect
--cache_latentsKeeps latents in RAM (fastest)
--cache_latents_to_diskOffloads latents to SSD (saves RAM)

Use both together on T4 to avoid OOM while maintaining reasonable speed.

The --lowram Patch

When the notebook detects a T4 GPU, it patches library/model_util.py to change cudacpu during model loading. This enables CPU offload for the initial load, preventing OOM before training even starts.


LoRA Types: What the Trainer Actually Supports

The Kohya trainer’s network_category dropdown (v14.6) offers four options:

TypeDescriptionTypical Use
LoRALinear + 1×1 Conv layersDefault; compatible with most Web UIs
LoConAdds 3×3 Conv LoRABetter for spatial features
LoCon_LycorisLyCORIS variant of LoConExperimental
LoHaHadamard product representationSlower training

Additional types (IA³, LoKR, DyLoRA-Lycoris) exist in the Kohya ecosystem, but require manual network_module + network_args configuration and are not in the UI dropdown.


Hosted Trainers: Web-Based Alternatives

When local cloud sessions timeout, consider hosted trainers that manage compute for you.

For architecture deep-dives, read LoRA implementation details.

Civitai On-Site Training

Civitai provides a built-in LoRA trainer. From any model page, click the “Train” button to launch a training job on Civitai’s GPU pool. You pay with compute credits.

Tensor.Art Online Training

Tensor.Art offers free daily quota for LoRA/LoCon training. Upload your dataset, set parameters, and the platform trains on dedicated GPUs. Results download automatically.

Replicate API

The ostris/sdxl-lora-trainer model on Replicate lets you train via API. Pay per second of GPU usage (A100/H100). Ideal for automation or integration into pipelines.

Hugging Face AutoTrain

AutoTrain Advanced supports SDXL LoRA training on HF’s GPU clusters. Point it at your dataset, choose hyperparameters, and let HF handle the compute.


Common Errors and Fixes

SymptomCauseFix
CUDA out of memoryfp32 optimizer exceeds 16 GBEnable --full_fp16
ValueError: fp16 mixed precision requires a GPUAccelerate config sees no GPUIn Q6, answer 0 (not all)
Model fails to load on T4Default loads to GPU before trainingApply lowram patch (sed -i 's@cpu@cuda@' library/model_util.py)
Kaggle session dies, /kaggle/working lostUsed /kaggle/temp for outputsWrite checkpoints to /kaggle/working; chain notebooks
Colab Drive mount failsOAuth blocked or wrong scopeUse drive.mount('/content/drive', force_remount=True)

Frequently Asked Questions

Why does my Colab disconnect after 90 minutes? Colab’s free tier kills idle sessions after 90 minutes. Enable “Keep alive” in the menu or use a browser extension to ping the runtime. For longer jobs, break training into smaller chunks and save checkpoints frequently.

How do I keep my LoRA checkpoints after a Kaggle session ends? Save checkpoints to /kaggle/working/ instead of /kaggle/temp/. After the session, the files persist as notebook output. Attach that output to a new notebook as a dataset to continue training.

Why does Kohya show double the epochs I set? The exact mechanism is undocumented. The UI may log optimizer steps rather than epochs, or count both text-encoder and UNet passes. Check the training log for actual step count.

Can I train IA³ or LoKR types on the Linaqruf Colab? Not through the network_category dropdown. These types require manual network_module and network_args configuration. The underlying sd-scripts may support them, but the Colab notebook does not expose them.

Is SDXL 0.9 still available on Hugging Face? SDXL 0.9 (stabilityai/stable-diffusion-xl-base-0.9) is deprecated. Current base models are SDXL 1.0 (stabilityai/stable-diffusion-xl-base-1.0) and community finetunes like AnimagineXL.

What’s the difference between --cache_latents and --cache_latents_to_disk? --cache_latents keeps all latents in RAM (fastest, uses VRAM). --cache_latents_to_disk writes them to SSD, freeing RAM. Use both together on 16 GB T4 GPUs to avoid OOM.

How much disk space do I need for Kaggle training? /kaggle/working gives 20 GB auto-saved. Use /kaggle/temp for up to 75 GB of temporary space. Download large models to /kaggle/temp/models/, but save final LoRAs to /kaggle/working/.


Sources

SourceWhat It Contributed
Google Colab FAQSession idle timeout (90 min), max VM lifetime (12h), Pro/Pro+ limits (24h)
Kaggle Notebooks docs20-min idle, 12h max run, 30h/week dual T4 quota, /kaggle/working 20 GB, /kaggle/temp scratch
kohya-ss/sd-scripts READMELoRA-LierLa and LoRA-C3Lier naming, accelerate fp16 fix, lowram context
Linaqruf/kohya-trainer READMEnetwork_category dropdown options (LoRA, LoCon, LoCon_Lycoris, LoHa), T4 auto-patch
Linaqruf/kohya-trainer XL notebookDefault model URLs, diffusers loading logic, hardware detection
FurkanGozukara SDXL tutorial30h/week claim, --full_fp16, --cache_latents, temp vs working dir
FurkanGozukara A1111 tutorialDrive/Dataset persistence pattern, ControlNet setup
Civitai Train pageHosted LoRA trainer exists, uses compute credits
Tensor.ArtOnline Training feature, free daily quota
Replicate ostris/sdxl-lora-trainerPay-per-second API training
Hugging Face AutoTrainSDXL LoRA support on dedicated GPUs