kohya-ss / kohya-ss/sd-scripts

Error in train_network.py UnicodeEncodeError: 'charmap' codec can't encode characters in position 27-42

Open
#232 5 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

im running into this error when starting the training. I have renamed all my files in case it was something with the filenames causing issues and it did not resolve it.

```
accelerate : Traceback (most recent call last):
At C:\Users\Aaron\sd-scripts\Train.ps1:28 char:1
+ accelerate launch --num_cpu_threads_per_process 8 train_network.py `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

File "C:\Users\Aaron\sd-scripts\train_network.py", line 507, in
train(args)
File "C:\Users\Aaron\sd-scripts\train_network.py", line 61, in train
train_dataset = DreamBoothDataset(args.train_batch_size, args.train_data_dir, args.reg_data_dir,
File "C:\Users\Aaron\sd-scripts\library\train_util.py", line 797, in __init__
print("no regularization images / \u6b63\u5247\u5316\u753b\u50cf\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f")
File "C:\Users\Aaron\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 27-42: character maps to
Traceback (most recent call last):
File "C:\Users\Aaron\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Aaron\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Aaron\sd-scripts\venv\Scripts\accelerate.exe\__main__.py", line 7, in
File "C:\Users\Aaron\sd-scripts\venv\lib\site-packages\accelerate\commands\accelerate_cli.py", line 45, in main
args.func(args)
File "C:\Users\Aaron\sd-scripts\venv\lib\site-packages\accelerate\commands\launch.py", line 1104, in launch_command
simple_launcher(args)
File "C:\Users\Aaron\sd-scripts\venv\lib\site-packages\accelerate\commands\launch.py", line 567, in simple_launcher
raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
subprocess.CalledProcessError: Command '['C:\\Users\\Aaron\\sd-scripts\\venv\\Scripts\\python.exe', 'train_network.py', '--network_module=networks.lora',
'--pretrained_model_name_or_path=C:\\Users\\Aaron\\sd-scripts\\Model', '--train_data_dir=C:\\Users\\Aaron\\sd-scripts\\Input\\Kulza',
'--reg_data_dir=C:\\Users\\Aaron\\sd-scripts\\Input\\Reg', '--output_dir=C:\\Users\\Aaron\\sd-scripts\\Output', '--caption_extension=.txt', '--shuffle_caption',
'--keep_tokens=1\n', '--prior_loss_weight=1', '--resolution=512', '--enable_bucket', '--min_bucket_reso=320', '--max_bucket_reso=960', '--train_batch_size=2',
'--learning_rate=0.0002', '--unet_lr=0.0002', '--text_encoder_lr=9E-05', '--max_train_epochs=8', '--mixed_precision=fp16', '--save_precision=fp16',
'--optimizer_type=AdamW8bit', '--xformers', '--save_every_n_epochs=1', '--save_model_as=safetensors', '--clip_skip=2', '--seed=420', '--flip_aug', '--network_dim=160',
'--network_alpha=128', '--max_token_length=225', '--cache_latents', '--lr_scheduler=cosine_with_restarts', '--noise_offset=0']' returned non-zero exit status 1.
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with library/train_util.py at line 797, where the traceback identifies the failing message, and review how train_network.py reaches DreamBoothDataset at line 61. Reproduce the training launch on Windows using the command and paths in the report. Done means the missing-regularization-images path no longer raises UnicodeEncodeError and training continues.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.