Skip to content

Commit 9ddb4d7

Browse files
committed
update readme and help message etc.
1 parent 8d1b1ac commit 9ddb4d7

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ The majority of scripts is licensed under ASL 2.0 (including codes from Diffuser
165165
- Specify the learning rate and dim (rank) for each block.
166166
- See [Block-wise learning rates in LoRA](./docs/train_network_README-ja.md#階層別学習率) for details (Japanese only).
167167

168+
- An option `--disable_mmap_load_safetensors` is added to disable memory mapping when loading the model's .safetensors in SDXL. PR [#1266](https://github.com/kohya-ss/sd-scripts/pull/1266) Thanks to Zovjsra!
169+
- It seems that the model file loading is faster in the WSL environment etc.
170+
- Available in `sdxl_train.py`, `sdxl_train_network.py`, `sdxl_train_textual_inversion.py`, and `sdxl_train_control_net_lllite.py`.
171+
168172
- Fixed some bugs when using DeepSpeed. Related [#1247](https://github.com/kohya-ss/sd-scripts/pull/1247)
169173

170174
- SDXL の学習時に Fused optimizer が使えるようになりました。PR [#1259](https://github.com/kohya-ss/sd-scripts/pull/1259) 2kpr 氏に感謝します。
@@ -193,6 +197,10 @@ The majority of scripts is licensed under ASL 2.0 (including codes from Diffuser
193197
- ブロックごとに学習率および dim (rank) を指定することができます。
194198
- 詳細は [LoRA の階層別学習率](./docs/train_network_README-ja.md#階層別学習率) をご覧ください。
195199

200+
- SDXL でモデルの .safetensors を読み込む際にメモリマッピングを無効化するオプション `--disable_mmap_load_safetensors` が追加されました。PR [#1266](https://github.com/kohya-ss/sd-scripts/pull/1266) Zovjsra 氏に感謝します。
201+
- WSL 環境等でモデルファイルの読み込みが高速化されるようです。
202+
- `sdxl_train.py``sdxl_train_network.py``sdxl_train_textual_inversion.py``sdxl_train_control_net_lllite.py` で使用可能です。
203+
196204
- DeepSpeed 使用時のいくつかのバグを修正しました。関連 [#1247](https://github.com/kohya-ss/sd-scripts/pull/1247)
197205

198206

library/sdxl_model_util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
from library import model_util
1010
from library import sdxl_original_unet
1111
from .utils import setup_logging
12+
1213
setup_logging()
1314
import logging
15+
1416
logger = logging.getLogger(__name__)
1517

1618
VAE_SCALE_FACTOR = 0.13025
@@ -171,8 +173,8 @@ def load_models_from_sdxl_checkpoint(model_version, ckpt_path, map_location, dty
171173
# Load the state dict
172174
if model_util.is_safetensors(ckpt_path):
173175
checkpoint = None
174-
if(disable_mmap):
175-
state_dict = safetensors.torch.load(open(ckpt_path, 'rb').read())
176+
if disable_mmap:
177+
state_dict = safetensors.torch.load(open(ckpt_path, "rb").read())
176178
else:
177179
try:
178180
state_dict = load_file(ckpt_path, device=map_location)

library/sdxl_train_util.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import torch
77
from library.device_utils import init_ipex, clean_memory_on_device
8+
89
init_ipex()
910

1011
from accelerate import init_empty_weights
@@ -13,8 +14,10 @@
1314
from library import model_util, sdxl_model_util, train_util, sdxl_original_unet
1415
from library.sdxl_lpw_stable_diffusion import SdxlStableDiffusionLongPromptWeightingPipeline
1516
from .utils import setup_logging
17+
1618
setup_logging()
1719
import logging
20+
1821
logger = logging.getLogger(__name__)
1922

2023
TOKENIZER1_PATH = "openai/clip-vit-large-patch14"
@@ -44,7 +47,7 @@ def load_target_model(args, accelerator, model_version: str, weight_dtype):
4447
weight_dtype,
4548
accelerator.device if args.lowram else "cpu",
4649
model_dtype,
47-
args.disable_mmap_load_safetensors
50+
args.disable_mmap_load_safetensors,
4851
)
4952

5053
# work on low-ram device
@@ -336,6 +339,7 @@ def add_sdxl_training_arguments(parser: argparse.ArgumentParser):
336339
parser.add_argument(
337340
"--disable_mmap_load_safetensors",
338341
action="store_true",
342+
help="disable mmap load for safetensors. Speed up model loading in WSL environment / safetensorsのmmapロードを無効にする。WSL環境等でモデル読み込みを高速化できる",
339343
)
340344

341345

0 commit comments

Comments
 (0)