Train a FLUX LoRA with Kohya sd-scripts
LoRA (Low-Rank Adaptation) fine-tunes a model on your own images by training a small set of extra weights instead of the whole model. This guide builds a character or style LoRA for FLUX.1 Dev with kohya-ss/sd-scripts, using its flux_train_network.py script. Options and VRAM guidance follow the sd-scripts FLUX documentation.
NeuralDrift has not yet published a recorded FLUX LoRA training run, so this guide gives no training-time figures. Time depends on GPU, dataset size, resolution, repeats, epochs and memory-saving options.
#Hardware Requirements
The sd-scripts FLUX documentation gives these starting points by VRAM:
| VRAM | sd-scripts recommendation |
|---|---|
| 24 GB | Basic settings work (batch size 2) |
| 16 GB | Batch size 1 and --blocks_to_swap |
| 12 GB | --blocks_to_swap 16 and 8-bit AdamW |
| 10 GB | --blocks_to_swap 22, fp8 T5-XXL recommended |
| 8 GB | --blocks_to_swap 28, fp8 T5-XXL recommended |
An RTX 5080 has 16 GB, so start from the 16 GB row. --blocks_to_swap moves transformer blocks between CPU and GPU. It saves VRAM at the cost of speed, and needs enough system RAM.
#Step 1 — Dataset Preparation
Training data quality drives most of the result.
- →Quantity: a small, varied set is common for a character, and a larger set for a style.
- →Resolution: 1024×1024 or larger source images. sd-scripts buckets mixed aspect ratios if you enable bucketing.
- →Variety: different angles, lighting and expressions for a character; diverse examples for a style.
- →Quality: sharp images with no compression artifacts or watermarks.
Folder Structure
sd-scripts' DreamBooth-style folder naming puts the repeat count in the folder name:
The number before the underscore is how many times each image is shown per epoch. Use more repeats for small datasets and fewer for large ones.
#Step 2 — Captioning
Every image needs a caption file with the same name. sd-scripts includes a WD14 tagger script that writes tag-style captions:
FLUX's T5 text encoder reads natural language, so many trainers write short sentence captions instead of tags, or edit the tagger output. Either way, start every caption with a unique trigger word:
The trigger word (mychar) is what you put in prompts to activate the LoRA.
#Step 3 — Install sd-scripts
Install PyTorch following the sd-scripts README, using a CUDA build that supports your GPU. RTX 50-series (Blackwell) cards need PyTorch built for CUDA 12.8 or newer, so older cu121 or cu124 commands will not work on an RTX 5080. Then:
#Step 4 — Training Command
FLUX.1 LoRA training needs four model files: the FLUX.1 model, CLIP-L, T5-XXL and the FLUX autoencoder (ae). This command follows the sd-scripts FLUX example, adjusted for 16 GB:
The ^ characters continue the command across lines in Windows Command Prompt. Use \ on Linux.
Several FLUX options matter more than they look:
- →
--guidance_scale 1.0: sd-scripts defaults to 3.5, and its docs say to set this explicitly; use 1.0 for FLUX.1. - →
--timestep_sampling flux_shiftand--model_prediction_type raw: the documented recommendations for FLUX.1. - →
--cache_text_encoder_outputs: caches CLIP-L and T5-XXL outputs once, which reduces memory use during training.
#network_dim (rank) and network_alpha
Searches for flux_train_network.py network_dim rank usually come down to two settings:
--network_dim is the LoRA rank. Each adapted layer gets two small matrices of this inner dimension. A higher rank gives the LoRA more capacity to learn detail. It also makes the file larger, uses more VRAM, and makes it easier to overfit a small dataset. The sd-scripts FLUX example uses 16. Characters and styles commonly use 16–32; going much higher mainly pays off for broad styles with large datasets.
--network_alpha scales the LoRA's effect. sd-scripts scales the learned weights by alpha / dim. With --network_dim 16 --network_alpha 1, updates are scaled by 1/16, which acts like a lower effective learning rate. Setting alpha equal to dim removes the scaling.
Because of that scaling, change dim and alpha together, and retest the learning rate. If you raise dim from 16 to 32 but keep alpha at 1, the effective step size halves. If results come out weak or undertrained after changing rank, raise the learning rate or alpha.
Per-layer ranks are also possible: the sd-scripts docs note that network_reg_dims inside --network_args overrides the global --network_dim for matching layers.
Other settings:
- →
--learning_rate:1e-4is a common start for FLUX LoRAs. Lower it if the LoRA overpowers prompts. - →
--max_train_epochs: save every couple of epochs and compare the checkpoints instead of trusting a single final file.
#Step 5 — Monitor Training
Run the command and watch the logged loss. It should trend down overall while fluctuating step to step. If it plateaus very early or spikes, lower the learning rate. To track runs, add --logging_dir C:/my_dataset/log and open the logs in TensorBoard.
#Step 6 — Evaluate Your LoRA
Test each saved checkpoint in ComfyUI with a fixed seed and prompt:
Start with LoRA strength 0.8 and adjust from about 0.6 (subtle) to 1.0 (strong).
Good signs:
- →The subject is recognizable at moderate strength
- →The prompt still controls background, lighting and pose
- →No artifacts or distortion
Bad signs:
- →Only activates near strength 1.0 or above (undertrained)
- →Everything looks like the subject, or prompts stop working (overtrained)
- →Noise or artifacts (learning rate too high)
#Step 7 — Use It in ComfyUI
Copy the trained .safetensors file to ComfyUI/models/loras/. Load it with a LoRA loader node between the model loader and the sampler, then set its strength.
#Common Issues
Out of memory at start. Make sure --train_batch_size 1, --gradient_checkpointing, --fp8_base and --cache_text_encoder_outputs are set, then raise --blocks_to_swap. Using an fp8 T5-XXL file also helps on 10–12 GB cards.
CUDA errors on an RTX 50-series card. Your PyTorch build predates Blackwell support. Reinstall PyTorch built for CUDA 12.8 or newer; see the ComfyUI RTX 5080 setup guide.
Loss not decreasing. Check that the captions are correct and the trigger word is consistent, and that the dataset folder name includes the repeat count.
Subject not activating. Train more epochs, raise the learning rate, or increase network_alpha relative to network_dim.
Overfitting. Use fewer epochs or repeats, a lower rank, or a more varied dataset.
Slow training. --blocks_to_swap trades speed for VRAM, so use the lowest value that fits. Keep latent and text-encoder caching on.