Prerequisites: license, GPU and VRAM
FLUX.1-dev is a 12 billion parameter rectified flow transformer released under the FLUX.1 [dev] Non-Commercial License. The repository is gated: sign in to Hugging Face, accept the license and acceptable use policy on the model page, then create a read token. The model card says generated outputs can be used for personal, scientific and commercial purposes as described in the license, so read it before you ship anything built on the weights or your LoRA.
VRAM depends on the trainer. The diffusers FLUX README warns that a rank-16 LoRA with all components trained can exceed 40 GB. ostris ai-toolkit ships an example config named train_lora_flux_24gb.yaml that quantizes the base model to 8-bit, which is how it targets a 24 GB card. For more on picking a card, see GPU for image generation and the planned FLUX.1 GPU requirements guide.
Leave plenty of free disk for the base model download, cached latents and checkpoints, and use a recent NVIDIA driver. The table summarizes the two documented routes.
| Trainer | Memory approach | Starting GPU |
|---|---|---|
| ostris ai-toolkit | 8-bit quantized base, 24 GB example config | 24 GB RTX 4090; 32 GB RTX 5090 for headroom |
| diffusers DreamBooth LoRA script | bf16 base; rank 16 can exceed 40 GB | 48 GB L40S or RTX A6000, or an 80 GB card |
References: Hugging Face model card: black-forest-labs/FLUX.1-dev · diffusers DreamBooth training for FLUX (README_flux.md) · ostris ai-toolkit example config train_lora_flux_24gb.yaml
Step 1: prepare the image dataset
Put your images in one folder. ai-toolkit supports jpg, jpeg and png only, and its README says webp currently has issues. Each image needs a caption file with the same name, so image2.jpg pairs with image2.txt. Images are resized and bucketed automatically to the resolutions in the config.
Pick a trigger token that the base model does not already associate with anything, such as p3r5on in ai-toolkit’s example or sks in the diffusers example, and put it in every caption or set trigger_word in the config. Describe what changes between images (pose, lighting, background) and leave the subject itself to the trigger token.
Check every image by eye before you start a paid run. Duplicates, watermarks and mismatched crops are learned just as faithfully as the subject.
References: ostris ai-toolkit README · ostris ai-toolkit example config train_lora_flux_24gb.yaml · diffusers DreamBooth training for FLUX (README_flux.md)
Step 2: install and run ai-toolkit
Clone with git clone https://github.com/ostris/ai-toolkit.git and cd ai-toolkit. Create an environment with python3 -m venv venv and source venv/bin/activate. Install PyTorch first, using the exact torch, torchvision and torchaudio versions and CUDA wheel index given in the README, then run pip3 install -r requirements.txt.
Log in with hf auth login using your read token. Copy config/examples/train_lora_flux_24gb.yaml into the config folder as my_lora.yml, set folder_path to your image folder, set name, and optionally trigger_word. Then run python run.py config/my_lora.yml inside tmux so a dropped SSH session does not stop the job.
The example saves a checkpoint every 250 steps, keeps the last four, and renders sample images every 250 steps from the prompts in the config. ai-toolkit also has a web UI started with npm run build_and_start in the ui folder on port 8675; on a cloud machine set AI_TOOLKIT_AUTH to a password, as the README recommends, or reach it through an SSH tunnel.
References: ostris ai-toolkit README · ostris ai-toolkit example config train_lora_flux_24gb.yaml
Step 2 alternative: the diffusers DreamBooth LoRA script
Clone diffusers with git clone https://github.com/huggingface/diffusers, cd diffusers and pip install -e . in a fresh environment. Then cd examples/dreambooth, run pip install -r requirements_flux.txt, and set up Accelerate with accelerate config default. LoRA training needs peft 0.6.0 or newer.
The README’s example launch is accelerate launch train_dreambooth_lora_flux.py with --pretrained_model_name_or_path=black-forest-labs/FLUX.1-dev, --instance_data_dir=dog, --output_dir=trained-flux-lora, --mixed_precision=bf16, --instance_prompt="a photo of sks dog", --resolution=512, --train_batch_size=1, --guidance_scale=1, --gradient_accumulation_steps=4, --optimizer=prodigy, --learning_rate=1.0, --lr_scheduler=constant, --lr_warmup_steps=0, --max_train_steps=500 and a --validation_prompt.
Prodigy needs pip install prodigyopt. Add --rank to set adapter size; the README suggests lora_alpha equal to rank as a starting point. To cut memory, add --gradient_checkpointing, keep resolution at 512, or switch to AdamW with --use_8bit_adam, which needs bitsandbytes. --cache_latents saves memory too, but only when you skip validation runs.
References: diffusers DreamBooth training for FLUX (README_flux.md)
Settings table for FLUX LoRA training
These are the documented example values from each trainer, not tuned recommendations for your subject. Change one at a time and judge by the sample images.
| Setting | ai-toolkit example | diffusers example | Notes |
|---|---|---|---|
| LoRA rank | linear: 16, alpha 16 | Set with --rank | Alpha equal to rank is a common start |
| Optimizer | adamw8bit | prodigy | 8-bit Adam applies only to AdamW |
| Learning rate | 1e-4 | 1.0 with Prodigy | Prodigy adapts its own step size |
| Steps | 2,000; 500-4,000 range | 500 | Watch samples for overfitting |
| Resolution | 512, 768 and 1024 buckets | 512 | Lower resolution reduces memory |
| Batch and accumulation | 1 and 1 | 1 and 4 | Accumulation lowers memory per update |
| Gradient checkpointing | On | Optional flag | Slower backward pass, less memory |
| Precision | bf16, base quantized to 8-bit | bf16 mixed precision | Saves in float16 or training precision |
References: ostris ai-toolkit example config train_lora_flux_24gb.yaml · diffusers DreamBooth training for FLUX (README_flux.md)
Step 3: load the LoRA and test it
Load the base model with pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to("cuda"), then pipe.load_lora_weights("trained-flux-lora", adapter_name="mine"). Diffusers documents load_lora_weights as the preferred way to load LoRA weights into the transformer and text encoders.
Generate with the trigger token in the prompt and the model card’s example settings, guidance_scale=3.5 and num_inference_steps=50, using a fixed seed. Compare the same prompts with pipe.disable_lora() to see what the adapter adds, and use pipe.set_adapters("mine", adapter_weights=0.8) to soften it. On a card with less memory, pipe.enable_model_cpu_offload() trades speed for VRAM.
Test several checkpoints, not only the last one. An earlier step often keeps more flexibility while a later one copies the training images more closely.
References: Hugging Face model card: black-forest-labs/FLUX.1-dev · Hugging Face diffusers: LoRA loading and adapters
Common errors when you train a FLUX LoRA
Most errors appear while the model downloads or in the first few steps, so watch the first five minutes closely.
| Error or symptom | Likely cause | Fix |
|---|---|---|
| 401 or gated repo error | License not accepted or no token | Accept terms on the FLUX.1-dev page; run hf auth login |
| CUDA out of memory with diffusers | Rank 16 bf16 training can exceed 40 GB | Add --gradient_checkpointing, --use_8bit_adam, resolution 512, or rent 48-80 GB |
| CUDA out of memory with ai-toolkit | Quantization or checkpointing turned off | Keep quantize: true and gradient_checkpointing: true |
| Images skipped or dataset empty | webp or other unsupported format | Convert to jpg or png |
| LoRA ignores the subject | Trigger token missing from captions | Add it to every caption or set trigger_word |
| Samples copy training images | Too many steps or too high a rate | Use an earlier checkpoint or fewer steps |
| Prodigy import error | prodigyopt not installed | pip install prodigyopt |
| --use_8bit_adam has no effect | Optimizer is Prodigy | Switch to AdamW to use 8-bit Adam |
References: diffusers DreamBooth training for FLUX (README_flux.md) · ostris ai-toolkit README · ostris ai-toolkit example config train_lora_flux_24gb.yaml · Hugging Face model card: black-forest-labs/FLUX.1-dev
Estimate training time and GPU-hours
Time per step is the only number you need, and you measure it. Start the run, note the seconds per step the trainer reports after 50 steps, and multiply by total steps. Add time for sample image rendering at each sample interval, the first model download, and latent caching.
An illustrative calculation with assumed inputs, not a benchmark: 2,000 steps at an assumed 1.5 seconds per step is 50 minutes. Add an assumed 10 minutes for sample rendering and 20 minutes for download and setup, and the run uses about 1.3 GPU-hours. At an assumed $1 per GPU-hour on a 24 GB card, that is about $1.30 per run, before the retries most subjects need.
For language-model adapters the cost logic is different; the LoRA fine-tuning cost guide covers it. Copy checkpoints off the machine as they appear, as described in GPU training checkpoints.
| Input (illustrative) | Value |
|---|---|
| Steps | 2,000 |
| Measured time per step (assumed) | 1.5 seconds |
| Training | ≈50 minutes |
| Sampling, download and setup (assumed) | ≈30 minutes |
| GPU-hours at $1 (assumed) | ≈1.3, about $1.30 |
References: ostris ai-toolkit example config train_lora_flux_24gb.yaml
Checklist and next step
Accept the FLUX.1-dev license and log in. Use jpg or png with matching txt captions and a unique trigger token. Pick ai-toolkit for 24 GB cards or diffusers with 48 GB or more. Keep quantization and gradient checkpointing on when memory is tight. Measure seconds per step after 50 steps. Save checkpoints off the machine and test several of them with a fixed seed.
A 24 GB RTX 4090 runs the ai-toolkit example config; a 48 GB L40S gives the diffusers script room. NeuraMesh rents both by the hour: choose GPU, plan, count, hours and region on rent GPUs, receive a confirmed quotation, typically within one business day, and pay only when you approve. If you are unsure which card fits, ask the compute advisor.
NeuraMesh prices for these GPUs
| GPU | Memory | Data center | Value |
|---|---|---|---|
| RTX 4090 | 24 GB | $0.46 | $0.40 |
| L40S | 48 GB | $1.26 | $0.54 |
| A100 | 80 GB | $1.56 | $0.98 |
| H100 | 80 GB | $2.88 | $2.00 |
Every order is confirmed in a quotation before you pay. See all GPU prices.
Questions readers ask
How much VRAM do I need to train a FLUX LoRA?
With ostris ai-toolkit’s example config, which quantizes the base model to 8-bit, the target is a 24 GB card. The diffusers DreamBooth script trains in bf16, and its README says a rank-16 LoRA with all components can exceed 40 GB, so plan for 48 GB or more there.
How many steps should a FLUX LoRA train for?
ai-toolkit’s example config uses 2,000 steps and comments that 500-4,000 is a good range. The diffusers example uses 500 steps with Prodigy. Save checkpoints often and pick the one whose samples look best.
Can I use FLUX LoRA outputs commercially?
The FLUX.1-dev model card says generated outputs can be used for personal, scientific and commercial purposes as described in the FLUX.1 [dev] Non-Commercial License. The weights themselves are non-commercial, so read the license terms before building a product on them.
What image formats does ai-toolkit accept?
jpg, jpeg and png. The README says webp currently has issues. Each image needs a caption file with the same base name and a .txt extension.
Should I train the text encoder?
Usually not. The diffusers README marks CLIP text encoder training as experimental and keeps T5 frozen, and ai-toolkit’s example sets train_text_encoder to false with a comment that it probably will not work with FLUX.
Sources and editorial notes
- Hugging Face model card: black-forest-labs/FLUX.1-dev
- diffusers DreamBooth training for FLUX (README_flux.md)
- ostris ai-toolkit example config train_lora_flux_24gb.yaml
- ostris ai-toolkit README
- Hugging Face diffusers: LoRA loading and adapters
Primary documentation reviewed November 24, 2026. Provider descriptions reflect published documentation. Recommendations are our analysis; worked figures are illustrative unless explicitly stated otherwise. No independent provider benchmark or uptime ranking is claimed.
Need this GPU? Rent it from NeuraMesh: choose a GPU and plan, get a confirmed quotation, and pay only when you approve. See pricing.

