kohya-ss / kohya-ss/sd-scripts

Error in deepspeed when training flux lora.

Open
#2,089 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
7.2k
Forks
1.2k
Avg merge
11m
Merged PRs (30d)
2

Description

Great work!
When training Flux LoRA with DeepSpeed, I encountered the following error:

`
ninja: build stopped: subcommand failed.
[rank0]: Traceback (most recent call last):
[rank0]: File "/path/to/python/site-packages/torch/utils/cpp_extension.py", line 2105, in _run_ninja_build
[rank0]: subprocess.run(
[rank0]: File "/path/to/python/subprocess.py", line 571, in run
[rank0]: raise CalledProcessError(retcode, process.args,
[rank0]: subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

[rank0]: The above exception was the direct cause of the following exception:

[rank0]: Traceback (most recent call last):
[rank0]: File "/path/to/project/flux_train_network.py", line 559, in
[rank0]: trainer.train(args)
[rank0]: File "/path/to/project/train_network.py", line 852, in train
[rank0]: ds_model, optimizer, train_dataloader, val_dataloader, lr_scheduler = accelerator.prepare(
[rank0]: ^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/path/to/python/site-packages/accelerate/accelerator.py", line 1303, in prepare
[rank0]: result = self._prepare_deepspeed(*args)
[rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/path/to/python/site-packages/accelerate/accelerator.py", line 1773, in _prepare_deepspeed
[rank0]: optimizer = DeepSpeedCPUAdam(optimizer.param_groups, **defaults)
[rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/path/to/python/site-packages/deepspeed/ops/adam/cpu_adam.py", line 94, in __init__
[rank0]: self.ds_opt_adam = CPUAdamBuilder().load()
[rank0]: ^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/path/to/python/site-packages/deepspeed/ops/op_builder/builder.py", line 540, in load
[rank0]: return self.jit_load(verbose)
[rank0]: ^^^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/path/to/python/site-packages/deepspeed/ops/op_builder/builder.py", line 587, in jit_load
[rank0]: op_module = load(name=self.name,
[rank0]: ^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/path/to/python/site-packages/torch/utils/cpp_extension.py", line 1312, in load
[rank0]: return _jit_compile(
[rank0]: ^^^^^^^^^^^^^
[rank0]: File "/path/to/python/site-packages/torch/utils/cpp_extension.py", line 1722, in _jit_compile
[rank0]: _write_ninja_file_and_build_library(
[rank0]: File "/path/to/python/site-packages/torch/utils/cpp_extension.py", line 1834, in _write_ninja_file_and_build_library
[rank0]: _run_ninja_build(
[rank0]: File "/path/to/python/site-packages/torch/utils/cpp_extension.py", line 2121, in _run_ninja_build
[rank0]: raise RuntimeError(message) from e
[rank0]: RuntimeError: Error building extension 'cpu_adam'
`

The versions of my libraries are as follows:
torch: 2.4.0+cu124
accelerate: 0.33.0
deepspeed: 0.16.7
ninja: 1.11.1.4

Could you kindly provide some assistance?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the Flux LoRA training failure at flux_train_network.py:559 and train_network.py:852 with the reported library versions. Inspect the DeepSpeed preparation path and the CPUAdamBuilder call shown in the traceback, then capture the omitted compiler output from the ninja build. Done means identifying a reproducible cause and documenting or fixing it with a verification run.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.