kohya-ss / kohya-ss/sd-scripts

ModuleNotFoundError: No module named 'xformers'

Open
#420 14 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
7.2k
Forks
1.2k
Avg merge
11m
Merged PRs (30d)
2

Description

I can't train a model with LoRA...

```
.....
[Dataset 0]
loading image sizes.
100%|████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 1537.39it/s]
make buckets
min_bucket_reso and max_bucket_reso are ignored if bucket_no_upscale is set, because bucket reso is defined by image size automatically / bucket_no_upscaleが指定された場合は、bucketの解像度は画像サイズから自動計算されるため、min_bucket_resoとmax_bucket_resoは無視されます
number of images (including repeats) / 各bucketの画像枚数(繰り返し回数を含む)
bucket 0: resolution (512, 512), count: 1500
mean ar error (without repeats): 0.0
prepare accelerator
Using accelerator 0.15.0 or above.
loading model for process 0/1
load StableDiffusion checkpoint
loading u-net:
loading vae:
loading text encoder:
Replace CrossAttention.forward to use xformers
Traceback (most recent call last):
File "H:\StableDiffusion\Kohya\kohya_ss\library\train_util.py", line 1764, in replace_unet_cross_attn_to_xformers
import xformers.ops
ModuleNotFoundError: No module named 'xformers'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "H:\StableDiffusion\Kohya\kohya_ss\train_network.py", line 760, in
train(args)
File "H:\StableDiffusion\Kohya\kohya_ss\train_network.py", line 167, in train
train_util.replace_unet_modules(unet, args.mem_eff_attn, args.xformers)
File "H:\StableDiffusion\Kohya\kohya_ss\library\train_util.py", line 1718, in replace_unet_modules
replace_unet_cross_attn_to_xformers()
File "H:\StableDiffusion\Kohya\kohya_ss\library\train_util.py", line 1766, in replace_unet_cross_attn_to_xformers
raise ImportError("No xformers / xformersがインストールされていないようです")
ImportError: No xformers / xformersがインストールされていないようです
Traceback (most recent call last):
File "C:\Users\GS\miniconda3\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\GS\miniconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "H:\StableDiffusion\Kohya\kohya_ss\venv\Scripts\accelerate.exe\__main__.py", line 7, in
File "h:\stablediffusion\kohya\kohya_ss\venv\lib\site-packages\accelerate\commands\accelerate_cli.py", line 45, in main
args.func(args)
File "h:\stablediffusion\kohya\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py", line 1104, in launch_command
simple_launcher(args)
File "h:\stablediffusion\kohya\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py", line 567, in simple_launcher
raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
subprocess.CalledProcessError: Command '['h:\\stablediffusion\\kohya\\kohya_ss\\venv\\scripts\\python.exe', 'train_network.py', '--enable_bucket', '--pretrained_model_name_or_path=H:/StableDiffusion/SD-Models/v1-5-pruned-emaonly.ckpt', '--train_data_dir=H:/StableDiffusion/Kohya/image', '--resolution=512,512', '--output_dir=H:/StableDiffusion/Kohya/models', '--logging_dir=H:/StableDiffusion/Kohya/logs', '--network_alpha=1', '--save_model_as=safetensors', '--network_module=networks.lora', '--text_encoder_lr=5e-5', '--unet_lr=0.0001', '--network_dim=8', '--output_name=hidezone', '--lr_scheduler_num_cycles=1', '--learning_rate=0.0001', '--lr_scheduler=constant', '--train_batch_size=1', '--max_train_steps=1500', '--save_every_n_epochs=1', '--mixed_precision=fp16', '--save_precision=fp16', '--cache_latents', '--optimizer_type=AdamW', '--max_data_loader_n_workers=0', '--bucket_reso_steps=64', '--xformers', '--bucket_no_upscale']' returned non-zero exit status 1.
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with library/train_util.py at replace_unet_cross_attn_to_xformers and library/train_util.py at replace_unet_modules, then trace the call from train_network.py. Reproduce the LoRA training command with --xformers and determine the expected behavior when the xformers import is unavailable. Done should be demonstrated by a relevant test or a confirmed, documented handling of this failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.