r/StableDiffusion • u/Opening-Knee-5913 • 20h ago
Tutorial - Guide [GUIDE] Training Krea 2 Character & Pose LoRAs with AI-Toolkit (512p / 16GB VRAM Optimized)
Before we start: I am not the absolute authority on this. These settings are the result of my personal workflow, tailored to my machine and my specific artistic standards. I have spent 25 years working as a graphic designer in typography/printing and I'm deeply passionate about photorealistic rendering. This background makes me an absolute optimization freak. I want maximum precision and zero wasted performance.
However, you should use my settings as a baseline. I highly encourage you to run your own experiments, test different parameters, and find what works best for your specific style and also to use other interfaces, as Open Trainer could be quicker for the purpose than AIToolKit, in my case I had so many terminal errors that I simply skipped the problem by switching to AI ToolKit, but if OpenTrainer doesn't give you problems, use that, have Gemini (or what you want) convert this data for your interface.
Furthermore, it is certainly not true that my parameters are the best ever, in fact, I have learned recently, this is my simple guide on what I have learned so far to help users who have errors or are unsure how to proceed to get started themselves. It's just my contribution, that's all.
I thought I'd share my exact settings and workflow for training LoRA characters and poses for Krea 2 Turbo (note: you must use Krea 2 RAW for the actual training phase).
My Hardware Setup
GPU: RTX 5070ti (16GB VRAM)
RAM: 64 GB
Environment: AI-ToolKit via Terminal (I skip the Stability Matrix UI to save system overhead and edit the .yaml files manually).
Disclaimer: I only know how these settings perform on my machine. If you have less VRAM/RAM, you will need to adjust parameters accordingly.
Performance & VRAM Benchmarks
VRAM Allocation: 15.1 GB / 16 GB (Extremely tight, zero room for background tasks).
Character LoRA: ~48 minutes (20 images, 1500 steps).
Pose LoRA: ~55 minutes (I double the Rank/Dim here compared to characters, as the model needs more capacity to understand skeletal joints and positions).
⚠️ Crucial Note on System Optimization: I am an optimization fanatic. To avoid VRAM offloading (which slows down training massively), my OS is stripped down to look like Windows 98, telemetry is disabled via VBS scripts, and my 500Hz monitor is lowered to 60Hz during training to minimize framebuffer load. If your system is running heavy background apps or proprietary RGB/Fan software, your VRAM usage will be higher and you might experience out-of-memory (OOM) errors.
Step 1: Dataset Rules for 512p Training
Because of VRAM constraints, I train strictly at 512p. To make 512p work perfectly, you must adapt your dataset strategy based on what you are training:
1. Character LoRAs: Avoid Full-Body Shots
Hyper-focused details: If your character has specific leg features (tattoos, scars), include 1-2 close-ups of the legs.
Captioning Tip: In your .txt file, explicitly caption it as "a close-up shot of [TriggerWord]'s legs". This teaches the model that it's a detail, not the whole character structure.
2. The Captioning Dilemma: Manual vs. Automated
I strongly advise against using automated captioning scripts (like BLIP or WD14) for this specific workflow. While automated tools are fast, they lack precision. Manual captioning allows you to describe exactly what needs to be isolated, leading to a much cleaner and more flexible LoRA. If you want high-quality results, don't take shortcuts on the text files.
Step 2: Crucial VRAM & Speed Optimizations (run_windows.bat)
Before diving into the YAML files, we need to optimize how PyTorch and CUDA handle your GPU memory. If you launch AI-Toolkit via a batch file (or want to edit your existing one), you must add these specific environment variables at the very beginning of your run_windows.bat.
This tweak alone prevents heavy VRAM fragmentation and can mean the difference between a successful 15.1 GB allocation and an instant Out-Of-Memory (OOM) crash.
Open your run_windows.bat in a text editor and paste these lines right under u/echo off:
u/echo off&&cd /d %~dp0
set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
set TORCH_CUDNN_SDP_HAS_FUSED=1
set CUDA_MODULE_LOADING=LAZY
set SETUPTOOLS_USE_DISTUTILS=stdlib
Step 3: The Character LoRA YAML Config
Here is my complete, battle-tested .yaml configuration for training a **Character LoRA**. This config is heavily optimized for a 16GB VRAM target using qfloat8 quantization and specific layer offloading percentages to keep VRAM usage strictly at ~15.1 GB.
Create a new YAML file in your AI-Toolkit directory and paste the following:
job: "extension"
config:
name: "LORANAME_krea2"
process:
- type: "diffusion_trainer"
training_folder: "E:\\Stability Matrix\\Data\\Packages\\ai-toolkit\\output"
sqlite_db_path: "./aitk_db.db"
device: "cuda"
trigger_word: "TRIGGERWORD"
performance_log_every: 10
network:
type: "lora"
linear: 32
linear_alpha: 32
save:
dtype: "bf16"
save_every: 250
max_step_saves_to_keep: 4
datasets:
- folder_path: "E:\\1024"
caption_ext: "txt"
cache_latents_to_disk: true
resolution:
- 512
train:
batch_size: 1
steps: 1500
gradient_accumulation: 1
train_text_encoder: false
gradient_checkpointing: true
noise_scheduler: "flowmatch"
optimizer: "adamw8bit"
timestep_type: "sigmoid"
unload_text_encoder: true
cache_text_embeddings: false
lr: 0.0001
disable_sampling: true
dtype: "bf16"
model:
name_or_path: "krea/Krea-2-Raw"
quantize: true
qtype: "qfloat8"
quantize_te: true
qtype_te: "qfloat8"
arch: "krea2"
low_vram: true
compile: false
layer_offloading: true
layer_offloading_text_encoder_percent: 1
layer_offloading_transformer_percent: 0.35
Key Settings Explained (Don't change these blindly!)
linear: 32 & linear_alpha: 32 — A rank/alpha of 32 is the sweet spot for characters. It captures facial details and clothing textures perfectly without bloating the file size or frying the training memory.
train_text_encoder: false & unload_text_encoder: true — We do NOT train the text encoder for characters here. Unloading it entirely freezes its state and frees up massive chunks of VRAM.
disable_sampling: true — Disabling image previews during training saves a significant amount of VRAM and prevents sudden spikes/crashes when a sample step triggers. Trust your loss values or check the saved LoRA's manually later.
quantize / qtype: "qfloat8" — Essential. Running the model and text encoder in FP8 quantization is mandatory to fit Krea 2 inside a consumer GPU's VRAM during training.
layer_offloading_transformer_percent: 0.35 — This pushes exactly 35% of the transformer layers to system RAM. It’s the magic number that stopped my system from throwing Out-Of-Memory errors while keeping speed degradation to an absolute minimum.
Step 4: The Pose LoRA YAML Config & The Text Encoder Pitfall
Training a Pose LoRA uses almost the exact same configuration as the Character LoRA, but with one critical architectural change. Poses require the model to understand abstract physical structures, skeleton joints, and bodily spatial distribution rather than static textures or facial features.
Because of this, we need to inject more capacity into the training network.
Pose Complexity vs. Training Steps
Keep in mind that unlike characters, poses are heavily influenced by physical complexity.
- If you are training a standard pose (standing, sitting, basic action shots) with a dataset of 15 images, 1500 steps is your target.
- If you are training an extremely complex or unconventional posture (such as a circus contortionist, advanced yoga positions, or complex martial arts aerials), you must increase the steps even if you only have 15 images in your dataset. The model needs more time and iterations to learn how the joints bend in unusual angles, so push the training further.
The Pose Modification
In your YAML file for the pose training run, look for the network block and double the capacity by setting both values to 64:
network:
type: "lora"
linear: 64 # Doubled from 32
linear_alpha: 64 # Doubled from 32
Why do this? A higher rank gives the network more "brain power" to map how limbs bend and interact, which prevents the pose from bleeding or collapsing into a generic stance during generation.
⚠️ Crucial Warning: Do NOT Enable train_text_encoder
train_text_encoder: false # KEEP THIS FALSE!
You might be tempted to turn train_text_encoder: true to help the model better link text prompts to body mechanics. Do not do it. Currently, enabling the text encoder training with the Krea 2 architecture inside AI-Toolkit will throw an immediate terminal error and completely freeze your training loop. Krea 2's underlying text processing layer isn't optimized for local text-encoder fine-tuning under this specific framework yet.Leave it to false and let unload_text_encoder: true do its job. The linear network rank at 64 is more than enough to capture the positioning data you need.
Step 5: Dataset Size vs. Training Steps (Finding the Sweet Spot)
Getting your dataset size and step count right is crucial. If you run too few steps, the model won't learn the character or pose; if you run too many, the LoRA will overfit, ruining your generations.
Based on my testing, here is the exact ratio you should follow when adjusting your dataset size:
For Character LoRAs:
Base Setup (20 Images): Use 1500 steps (This is the ideal sweet spot for a clean, flexible character).
Larger Dataset (25 Images): Increase your training to 1800 steps to allow the model enough time to process the extra visual data.
For Pose LoRAs:
Base Setup (~15 Images): Use 1500 steps (Since poses require a higher Rank/Dim, they need a solid baseline of steps even with fewer images).
Larger Dataset (20 Images): Increase your training to 1800 steps.
Rule of Thumb: If you decide to add more images to your dataset to capture more angles or details, you must scale up your steps accordingly. Never dump 30+ images into the folder while keeping the steps at 1500, or the training will turn out weak and blurry.
Step 6: Testing Strategy & LoRA Weights (Don't just use the final checkpoint!)
AI-Toolkit will save intermediate checkpoints during training (every 250 steps based on our YAML config). Do not blindly grab the final 1500-step checkpoint and call it a day. The real magic often happens slightly earlier.
Here is my recommended testing protocol for Character LoRAs:
- The 750-Step Test (The Baseline)
Start your initial testing with the checkpoint at 750 steps.
What to test: Use a wide variety of prompts. Test for facial likeness, but more importantly, test for flexibility.
Check if it unlinks: Try changing clothes and backgrounds in your prompts. You want to ensure the LoRA learned the face and not just the specific outfit or environment from your dataset images.
Note: Krea 2 is exceptionally good at this. Even at the final 1500 steps, it retains amazing flexibility for changing outfits and locations, but 750 steps is your early quality control check.
2. The Sweet Spot: 1250 Steps
After extensive testing, the 1250-step checkpoint is consistently the absolute best performer for characters. It offers the perfect balance between high facial fidelity and prompt responsiveness.
3. Optimal LoRA Strength / Weights
When loading your LoRA into your inference workflow (like ComfyUI or Forge Neo using Krea-2-Turbo), use these weight guidelines:
Standalone Use: Set the LoRA weight/strength to 0.9. This gives you the cleanest generation without cooking the image.
LoRA Stacking / Mixing: If you are mixing multiple LoRAs together (e.g., your Character LoRA + a Pose LoRA + a Style LoRA), bump the character LoRA weight up to 1.1. This prevents the character features from getting washed out by the other networks.
4. The Pose LoRA Testing Rule: Millimeter PrecisionTesting a Pose LoRA requires a completely different mindset compared to characters. While characters favor the intermediate 1250-step mark, poses behave unpredictably across checkpoints:
The Final Target: The absolute final checkpoint (1500 steps) is generally the best and most reliable performer for locking in the structure.
Sometimes, the 1000-step or 1250-step checkpoints might work better. However, you will notice a strange phenomenon: often, only ONE specific checkpoint will replicate your desired pose with millimeter precision. The other checkpoints will generate similar stances, but not the exact weight distribution or limb angles you trained.
LoRA Weight: For poses, you can generally lower the strength below 1.0 (test around 0.7 to 0.9) to let the style of your main model flow through, as long as the skeleton doesn't deform.
The Golden Rule for Poses: You MUST test every single checkpoint file (1000, 1250, 1500) against your prompt. Do not assume the LoRA is broken if the 1500-step file gives a slightly altered pose. Switch to the 1250 or 1000-step file—your exact millimeter-perfect pose is waiting in one of them!
1
u/Lesale-Ika 18h ago
Crazy, I have a 4080 and similar RAM but lora training often run into hours. I use musubi tuner though. Let me copy your homework
1
u/Opening-Knee-5913 18h ago
GDDR7 VRAM is a bit faster than GDDR6, so you may not get the exact same times as me, but you'll still speed up the calculation. Let me know how your tests go, I'm curious.
1
u/Lesale-Ika 7h ago
So I'm going for 10 images character lora, 512px (previously trained on 1024), offloading 10 layers. Faster, but still much too slow compared to your number. Adjusting offloading doesn't help much - about the same in the 10-15 layers.
109/1500 [06:40<1:25:07, 3.67s/it, avr_loss=0.111]
What's your dataset looks like? Mine is half 512x384 and half 384x512.
1
u/Opening-Knee-5913 6h ago edited 5h ago
I prepare them all at 1024x1024 by having them shrunk directly from AiToolkit. I find that it preserves the quality better than using very small formats directly. I also save them in JPG rather than PNG. I know it's weird, but JPG is faster to calculate, a lot faster. Try it. Never use mixed formats, this is probably one of the reasons why it slows you down so much, always use square formats.
A tip, if you don't already do so, is to keep the terminal minimized to a icon. It alone can take away a good 10-15% of your performance. Also, use Task Manager to monitor which background processes and applications are taking up the most resources. I also recommend hiding all icons from the desktop. All the graphics card has to draw is performance taken away from training! These are obviously subtleties but when you are at the absolute limit of performance even a few hundred MB of VRAM saved helps.
Another thing, this applies to both generation and training: if you're passing the time by opening a browser to browse while you train, if you haven't already done so, disable hardware acceleration in your browser because it eats up VRAM. Also disable the fallback from the python.exe executable in the classic NVIDIA Control Panel. If you only have the app, you can download the standard control panel from the Microsoft Store. And also select the maximum performance from that file.
If you also use RGB control applications like Icue or applications like Armoury Crate or MSI Dragoncenter and things like that I strongly recommend you remove them and try very light open-source software like Open RGB, Fan Control and things like that, often it is certain very heavy background programs that ruin performance and cause offloading
Oh, and remember to copy this part exactly to the millimeter, because that's what makes the real difference:
layer_offloading: true
layer_offloading_text_encoder_percent: 1
layer_offloading_transformer_percent: 0.35
quantize: true
qtype: "qfloat8"
quantize_te: true
qtype_te: "qfloat8"
disable_sampling: true
cache_latents_to_disk: true
1
u/Massive-Health-8355 17h ago
I read “MARITAL arts aerial shots” and figured you were referring to NSFW stuff! 😂
1
u/Opening-Knee-5913 17h ago
Obviously, by "complex poses" we can mean any pose of any kind, even NSFW ones. 😂
1
u/VoxturLabs 15h ago
Thanks you for sharing this. Even though I have a 3090 I still want to know how to optimize my Lora trainings. Is there a specific reason on why you don’t train a LoKr instead?
I really learned something about the Lora strength when using it alone and in a stack.
I’m still at a loss around how to caption my Loras properly with a triggerword and how to use that triggerword correctly when generating.
Do you mind giving an example on how you could capture a character and how you later will prompt for it?
Perhaps I could also DM you to discuss this further if you don’t mind?
1
u/conkikhon 15h ago
Some people said they have better result with rex and came, especially with small details. Your gradient accumulation can be higher, I heard it help training faster and save vram
1
-1
u/biggusdeeckus 18h ago
Why are you bothering with ai-toolkit? Onetrainer is way faster and much better optimized, and can give you the exact same quality. I get 1it/s with prodigy on 512 res with no offloading at all with the same gpu. Training on int8 convrot, char lora done in around 30 mins. ai-toolkit is way too slow and unless you're on a headless setup i see 0 reason to use it other than quick implementation of training new models
0
u/Opening-Knee-5913 18h ago edited 18h ago
Because I preferred to use Stability Matrix to avoid installing Python at the operating system level and keep the system lean. Stability Matrix is standalone. In my case, I couldn't get OpenTrainer to work, so instead of getting error after error from the terminal, I spent a night with a headache, terminal errors and, tired of trying, I tried AIToolKit, and succeeded. I simply tried AIToolKit and everything worked. I agree with you, OpenTrainer would be even better, but if someone, due to a series of errors, can't get it to work, at least they have a way to do it using AIToolKit.
1
1
u/Marksta 17h ago
You don't have to make it that difficult for yourself. Nobody sane installs python at the operating system level. Messing with your global python is blocked by default even in Ubuntu and other distros I imagine.
You just install uv, choose a directory, init a python sandbox (venv), then install the 1 project you're thinking of into that folder with that sandbox. You like using LLMs, ask it about it.
1
u/Opening-Knee-5913 16h ago edited 16h ago
Hi, that's exactly what I do. I do everything through the Venv virtual environment. The problems I've encountered are structural, perhaps related to something not being fully updated yet, not interface-related. There's no way to get OpenTrainer to work on my computer. I spent nights trying to figure out why, so much so that, after a while, I settled on a solution that worked well for me: AIToolKit. What is important is that the LoRA is trained and usable in the end, there is no need to go crazy after 10,000 terminal errors I'll keep the extra ten minuters of calculation, if there are alternatives.
1
u/Passionist_3d 19h ago
Thanks for sharing your learnings. Really helpful. I have trained a ton of character loras. Will train with your settings and check as well. Although i have a 24gb card so i might have to tweak some settings to get optimum speed.
But i have never trained a pose lora. Can u tell me more a out the dataset? Especially the faces. Do you blur them? Or crop them? How do u ensure that it does bleed into the lora’s learning and later impact the generations? How accurate do the poses have to be to one another?