Stuck at "Generating baseline samples before training"
This is for bugs only
Did you already ask in the discord?
No Discord
You verified that this is a bug and not a feature request or question by asking in the discord?
Yes
Describe the bug
When training a FLUX LoRA, the process gets stuck at the "Generating baseline samples before training" stage. It can remain in this state for hours with no progress or errors, even though the GPU is being utilized. Despite this activity, no LoRA model or images are generated. Interestingly, using the exact same settings with SDXL works immediately, and the baseline images are generated without delay.
I am using Windows 11, Python 3.12 (Miniconda).
EDIT: Tried with Python 3.10 (different versions) and still the same with FLUX lora training.
Generating baseline samples before training
Generating Images: 0%| | 0/1 [00:00<?, ?it/s]
Me too with SDXL. Sad
From what I can understand (if correct), it switches from training to generating, and that's where the problem seems to happen.
Dont know how to fix, hopefully someone does.
i removed all prompts because I don't want to generate a sample. is there any way to disable sample generating otherthan removing prompts
I dont know.
Do you have the correct CUDA version? It has to be CUDA 12.6. Fixed the problem for me.
Do you have the correct CUDA version? It has to be CUDA 12.6. Fixed the problem for me.
I might try re-install and see if that works. Will write tomorrow if it fixed it.
EDIT: I had a newer version so I un-installed and installed again. It did not work. Same problem/error/bug.
Do you have the correct CUDA version? It has to be CUDA 12.6. Fixed the problem for me.
Because you mean the Cuda Toolkit version "nvcc -V"? Or the driver installed "nvidia-smi"
nvcc -V:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Fri_Jun_14_16:44:19_Pacific_Daylight_Time_2024
Cuda compilation tools, release 12.6, V12.6.20
Build cuda_12.6.r12.6/compiler.34431801_0
I mean the the Cuda Toolkit Version. But it looks like you have the same version as me installed.
For the installation I used the .bat file from Aitrepreneur. That's there I got the hint for the Cuda version. https://www.patreon.com/posts/1-click-install-134551276?utm_medium=clipboard_copy&utm_source=copyLink&utm_campaign=postshare_fan&utm_content=web_share
I just looked into the install file and it says the following: RTX 50-series needs Cuda 12.8 RTX 40/30/20-sreies needs Cuda 12.6
So maybe I gave you the wrong Cuda version.
But maybe it is the install file itself that has a fix inside. I first tried cloning the repo myself but ran into the same issue like you. After using the bat file and installing Cuda 12.6 for my 4090 it worked.
I mean the the Cuda Toolkit Version. But it looks like you have the same version as me installed.
For the installation I used the .bat file from Aitrepreneur. That's there I got the hint for the Cuda version. https://www.patreon.com/posts/1-click-install-134551276?utm_medium=clipboard_copy&utm_source=copyLink&utm_campaign=postshare_fan&utm_content=web_share
I just looked into the install file and it says the following: RTX 50-series needs Cuda 12.8 RTX 40/30/20-sreies needs Cuda 12.6
So maybe I gave you the wrong Cuda version.
But maybe it is the install file itself that has a fix inside. I first tried cloning the repo myself but ran into the same issue like you. After using the bat file and installing Cuda 12.6 for my 4090 it worked.
I'm a bit hesitant to pay for a "maybe it works" situation. I've got an RTX 3060 and CUDA 12.6, so in theory it should run fine then. Are there any other changes in the installation that could be the reason it's working?
I can understand that. I took a look at the installation file. There doesn't seem to be any real deviation from the installation instructions here on GitHub.
The problem appears when VRAM is exceeded and Shared Memory is used for inference.
nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2024 NVIDIA Corporation Built on Thu_Sep_12_02:55:00_Pacific_Daylight_Time_2024 Cuda compilation tools, release 12.6, V12.6.77 Build cuda_12.6.r12.6/compiler.34841621_0
You have to make sure that samples are 1 frame images not videos. If you generate more frames for samples, it will expand into Shared Memory and basically stop.
WAN 2.1 14B training on 24GB of VRAM only works on portraits as options for "Low VRAM" and "Unload TE" need to be selected.
The only configuration working with full captions and sampling within 24 GB was WAN 2.1 1.3B when low VRAM is enabled.
Getting this while training sdxl lora. I see no gpus assigned in dashboard and my cpu loads to 70-80%. So I guess it for some reason refuses to assign a gpu for a job and tries to run on cpu instead.
UPD: yeah the problem was that my CUDA was 2.8 while 2.6 is needed
I can understand that. I took a look at the installation file. There doesn't seem to be any real deviation from the installation instructions here on GitHub.
I really want this to work so I payed and...drumrolls...it didn't work.
CPU is 2% in use. GPU is maxed. So it seems like its not using CPU.
I can confirm that I am experiencing this issue as well training on ai-toolkit/Wan2.2-I2V-A14B-Diffusers-bf16
nvcc -v
$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2025 NVIDIA Corporation
Built on Wed_Aug_20_13:58:20_Pacific_Daylight_Time_2025
Cuda compilation tools, release 13.0, V13.0.88
Build cuda_13.0.r13.0/compiler.36424714_0
Am using Cache TE and Low VRAM settings.
It is stuck after the first sample generation. Last message:
...
Unloading transformer
Loading Vae
my_lora: 0%| | 0/3000 [00:00<?, ?it/s]
Full job config:
{
"job": "extension",
"config": {
"name": "my_lora",
"process": [
{
"type": "diffusion_trainer",
"training_folder": "C:\\Users\\olive\\workspace\\AI-Toolkit-Easy-Install\\AI-Toolkit-Easy-Install\\AI-Toolkit\\output",
"sqlite_db_path": "C:\\Users\\olive\\workspace\\AI-Toolkit-Easy-Install\\AI-Toolkit-Easy-Install\\AI-Toolkit\\aitk_db.db",
"device": "cuda",
"trigger_word": null,
"performance_log_every": 10,
"network": {
"type": "lora",
"linear": 16,
"linear_alpha": 16,
"conv": 16,
"conv_alpha": 16,
"lokr_full_rank": true,
"lokr_factor": -1,
"network_kwargs": {
"ignore_if_contains": []
}
},
"save": {
"dtype": "bf16",
"save_every": 250,
"max_step_saves_to_keep": 4,
"save_format": "diffusers",
"push_to_hub": false
},
"datasets": [
{
"folder_path": "C:\\Users\\olive\\workspace\\AI-Toolkit-Easy-Install\\AI-Toolkit-Easy-Install\\AI-Toolkit\\datasets/my_lora",
"mask_path": null,
"mask_min_value": 0.1,
"default_caption": "",
"caption_ext": "txt",
"caption_dropout_rate": 0.05,
"cache_latents_to_disk": false,
"is_reg": false,
"network_weight": 1,
"resolution": [
512,
768
],
"controls": [],
"shrink_video_to_frames": true,
"num_frames": 81,
"do_i2v": true,
"flip_x": false,
"flip_y": false
}
],
"train": {
"batch_size": 1,
"bypass_guidance_embedding": false,
"steps": 3000,
"gradient_accumulation": 1,
"train_unet": true,
"train_text_encoder": false,
"gradient_checkpointing": true,
"noise_scheduler": "flowmatch",
"optimizer": "adamw8bit",
"timestep_type": "linear",
"content_or_style": "balanced",
"optimizer_params": {
"weight_decay": 0.0001
},
"unload_text_encoder": false,
"cache_text_embeddings": true,
"lr": 0.0001,
"ema_config": {
"use_ema": false,
"ema_decay": 0.99
},
"skip_first_sample": false,
"force_first_sample": false,
"disable_sampling": false,
"dtype": "bf16",
"diff_output_preservation": false,
"diff_output_preservation_multiplier": 1,
"diff_output_preservation_class": "person",
"switch_boundary_every": 10,
"loss_type": "mse"
},
"logging": {
"log_every": 1,
"use_ui_logger": true
},
"model": {
"name_or_path": "ai-toolkit/Wan2.2-I2V-A14B-Diffusers-bf16",
"quantize": true,
"qtype": "qfloat8",
"quantize_te": true,
"qtype_te": "qfloat8",
"arch": "wan22_14b_i2v",
"low_vram": true,
"model_kwargs": {
"train_high_noise": true,
"train_low_noise": true
},
"layer_offloading": true,
"layer_offloading_text_encoder_percent": 0.1,
"layer_offloading_transformer_percent": 0.1
},
"sample": {
"sampler": "flowmatch",
"sample_every": 250,
"width": 1024,
"height": 1024,
"samples": [
{
"prompt": "my_prompt",
"ctrl_img": "C:\\Users\\olive\\workspace\\AI-Toolkit-Easy-Install\\AI-Toolkit-Easy-Install\\AI-Toolkit\\data\\images\\8b3f736f-67e3-4676-876a-03c93bf004d2.PNG",
"width": 480,
"height": 832
},
{
"prompt": "my_prompt",
"ctrl_img": "C:\\Users\\olive\\workspace\\AI-Toolkit-Easy-Install\\AI-Toolkit-Easy-Install\\AI-Toolkit\\data\\images\\371fa1b0-4341-4938-8d9c-91d843a9ac4d.PNG",
"width": 480,
"height": 832
},
{
"prompt": "my_prompt",
"ctrl_img": "C:\\Users\\olive\\workspace\\AI-Toolkit-Easy-Install\\AI-Toolkit-Easy-Install\\AI-Toolkit\\data\\images\\62c5e5f7-4e6c-4fda-a94a-ed61de691a4e.png",
"width": 480,
"height": 832
},
{
"prompt": "my_prompt",
"ctrl_img": "C:\\Users\\olive\\workspace\\AI-Toolkit-Easy-Install\\AI-Toolkit-Easy-Install\\AI-Toolkit\\data\\images\\af9577a1-a455-491b-9f89-1f7fdc0e8501.PNG",
"width": 480,
"height": 832
}
],
"neg": "",
"seed": 42,
"walk_seed": true,
"guidance_scale": 4,
"sample_steps": 25,
"num_frames": 41,
"fps": 16
}
}
]
},
"meta": {
"name": "[name]",
"version": "1.0"
}
}
I'm running into the same problem. Turning off samples makes it go. But I'd like to see the progress.
I updated to the latest ai-toolkit (git pull), same thing when training, however I did do conda update conda and now it works. Don't know if it is related, probably not.
- Preprocessing image dimensions
100%|##########| 29/29 [00:00<00:00, 29029.79it/s]
Generally, this issue is on windows and happens because the computer runs out of VRAM, and windows does its "slowest possible method in the world" to auto swap off vram to keep it from OOMing, which slows everything down 100000x