Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
diffusers
Commits
6fedb29f
Unverified
Commit
6fedb29f
authored
Jan 23, 2023
by
Suraj Patil
Committed by
GitHub
Jan 23, 2023
Browse files
[examples] add dataloader_num_workers argument (#2070)
add --dataloader_num_workers argument
parent
d75ad93c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
5 deletions
+55
-5
examples/dreambooth/train_dreambooth.py
examples/dreambooth/train_dreambooth.py
+9
-1
examples/dreambooth/train_dreambooth_lora.py
examples/dreambooth/train_dreambooth_lora.py
+9
-1
examples/text_to_image/train_text_to_image.py
examples/text_to_image/train_text_to_image.py
+13
-1
examples/text_to_image/train_text_to_image_lora.py
examples/text_to_image/train_text_to_image_lora.py
+13
-1
examples/textual_inversion/textual_inversion.py
examples/textual_inversion/textual_inversion.py
+11
-1
No files found.
examples/dreambooth/train_dreambooth.py
View file @
6fedb29f
...
@@ -240,6 +240,14 @@ def parse_args(input_args=None):
...
@@ -240,6 +240,14 @@ def parse_args(input_args=None):
parser
.
add_argument
(
parser
.
add_argument
(
"--use_8bit_adam"
,
action
=
"store_true"
,
help
=
"Whether or not to use 8-bit Adam from bitsandbytes."
"--use_8bit_adam"
,
action
=
"store_true"
,
help
=
"Whether or not to use 8-bit Adam from bitsandbytes."
)
)
parser
.
add_argument
(
"--dataloader_num_workers"
,
type
=
int
,
default
=
0
,
help
=
(
"Number of subprocesses to use for data loading. 0 means that the data will be loaded in the main process."
),
)
parser
.
add_argument
(
"--adam_beta1"
,
type
=
float
,
default
=
0.9
,
help
=
"The beta1 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_beta1"
,
type
=
float
,
default
=
0.9
,
help
=
"The beta1 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_beta2"
,
type
=
float
,
default
=
0.999
,
help
=
"The beta2 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_beta2"
,
type
=
float
,
default
=
0.999
,
help
=
"The beta2 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_weight_decay"
,
type
=
float
,
default
=
1e-2
,
help
=
"Weight decay to use."
)
parser
.
add_argument
(
"--adam_weight_decay"
,
type
=
float
,
default
=
1e-2
,
help
=
"Weight decay to use."
)
...
@@ -652,7 +660,7 @@ def main(args):
...
@@ -652,7 +660,7 @@ def main(args):
batch_size
=
args
.
train_batch_size
,
batch_size
=
args
.
train_batch_size
,
shuffle
=
True
,
shuffle
=
True
,
collate_fn
=
lambda
examples
:
collate_fn
(
examples
,
args
.
with_prior_preservation
),
collate_fn
=
lambda
examples
:
collate_fn
(
examples
,
args
.
with_prior_preservation
),
num_workers
=
1
,
num_workers
=
args
.
dataloader_num_workers
,
)
)
# Scheduler and math around the number of training steps.
# Scheduler and math around the number of training steps.
...
...
examples/dreambooth/train_dreambooth_lora.py
View file @
6fedb29f
...
@@ -285,6 +285,14 @@ def parse_args(input_args=None):
...
@@ -285,6 +285,14 @@ def parse_args(input_args=None):
help
=
"Number of hard resets of the lr in cosine_with_restarts scheduler."
,
help
=
"Number of hard resets of the lr in cosine_with_restarts scheduler."
,
)
)
parser
.
add_argument
(
"--lr_power"
,
type
=
float
,
default
=
1.0
,
help
=
"Power factor of the polynomial scheduler."
)
parser
.
add_argument
(
"--lr_power"
,
type
=
float
,
default
=
1.0
,
help
=
"Power factor of the polynomial scheduler."
)
parser
.
add_argument
(
"--dataloader_num_workers"
,
type
=
int
,
default
=
0
,
help
=
(
"Number of subprocesses to use for data loading. 0 means that the data will be loaded in the main process."
),
)
parser
.
add_argument
(
parser
.
add_argument
(
"--use_8bit_adam"
,
action
=
"store_true"
,
help
=
"Whether or not to use 8-bit Adam from bitsandbytes."
"--use_8bit_adam"
,
action
=
"store_true"
,
help
=
"Whether or not to use 8-bit Adam from bitsandbytes."
)
)
...
@@ -746,7 +754,7 @@ def main(args):
...
@@ -746,7 +754,7 @@ def main(args):
batch_size
=
args
.
train_batch_size
,
batch_size
=
args
.
train_batch_size
,
shuffle
=
True
,
shuffle
=
True
,
collate_fn
=
lambda
examples
:
collate_fn
(
examples
,
args
.
with_prior_preservation
),
collate_fn
=
lambda
examples
:
collate_fn
(
examples
,
args
.
with_prior_preservation
),
num_workers
=
1
,
num_workers
=
args
.
dataloader_num_workers
,
)
)
# Scheduler and math around the number of training steps.
# Scheduler and math around the number of training steps.
...
...
examples/text_to_image/train_text_to_image.py
View file @
6fedb29f
...
@@ -209,6 +209,14 @@ def parse_args():
...
@@ -209,6 +209,14 @@ def parse_args():
" remote repository specified with --pretrained_model_name_or_path."
" remote repository specified with --pretrained_model_name_or_path."
),
),
)
)
parser
.
add_argument
(
"--dataloader_num_workers"
,
type
=
int
,
default
=
0
,
help
=
(
"Number of subprocesses to use for data loading. 0 means that the data will be loaded in the main process."
),
)
parser
.
add_argument
(
"--adam_beta1"
,
type
=
float
,
default
=
0.9
,
help
=
"The beta1 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_beta1"
,
type
=
float
,
default
=
0.9
,
help
=
"The beta1 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_beta2"
,
type
=
float
,
default
=
0.999
,
help
=
"The beta2 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_beta2"
,
type
=
float
,
default
=
0.999
,
help
=
"The beta2 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_weight_decay"
,
type
=
float
,
default
=
1e-2
,
help
=
"Weight decay to use."
)
parser
.
add_argument
(
"--adam_weight_decay"
,
type
=
float
,
default
=
1e-2
,
help
=
"Weight decay to use."
)
...
@@ -515,7 +523,11 @@ def main():
...
@@ -515,7 +523,11 @@ def main():
# DataLoaders creation:
# DataLoaders creation:
train_dataloader
=
torch
.
utils
.
data
.
DataLoader
(
train_dataloader
=
torch
.
utils
.
data
.
DataLoader
(
train_dataset
,
shuffle
=
True
,
collate_fn
=
collate_fn
,
batch_size
=
args
.
train_batch_size
train_dataset
,
shuffle
=
True
,
collate_fn
=
collate_fn
,
batch_size
=
args
.
train_batch_size
,
num_workers
=
args
.
dataloader_num_workers
,
)
)
# Scheduler and math around the number of training steps.
# Scheduler and math around the number of training steps.
...
...
examples/text_to_image/train_text_to_image_lora.py
View file @
6fedb29f
...
@@ -245,6 +245,14 @@ def parse_args():
...
@@ -245,6 +245,14 @@ def parse_args():
" https://pytorch.org/docs/stable/notes/cuda.html#tensorfloat-32-tf32-on-ampere-devices"
" https://pytorch.org/docs/stable/notes/cuda.html#tensorfloat-32-tf32-on-ampere-devices"
),
),
)
)
parser
.
add_argument
(
"--dataloader_num_workers"
,
type
=
int
,
default
=
0
,
help
=
(
"Number of subprocesses to use for data loading. 0 means that the data will be loaded in the main process."
),
)
parser
.
add_argument
(
"--adam_beta1"
,
type
=
float
,
default
=
0.9
,
help
=
"The beta1 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_beta1"
,
type
=
float
,
default
=
0.9
,
help
=
"The beta1 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_beta2"
,
type
=
float
,
default
=
0.999
,
help
=
"The beta2 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_beta2"
,
type
=
float
,
default
=
0.999
,
help
=
"The beta2 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_weight_decay"
,
type
=
float
,
default
=
1e-2
,
help
=
"Weight decay to use."
)
parser
.
add_argument
(
"--adam_weight_decay"
,
type
=
float
,
default
=
1e-2
,
help
=
"Weight decay to use."
)
...
@@ -583,7 +591,11 @@ def main():
...
@@ -583,7 +591,11 @@ def main():
# DataLoaders creation:
# DataLoaders creation:
train_dataloader
=
torch
.
utils
.
data
.
DataLoader
(
train_dataloader
=
torch
.
utils
.
data
.
DataLoader
(
train_dataset
,
shuffle
=
True
,
collate_fn
=
collate_fn
,
batch_size
=
args
.
train_batch_size
train_dataset
,
shuffle
=
True
,
collate_fn
=
collate_fn
,
batch_size
=
args
.
train_batch_size
,
num_workers
=
args
.
dataloader_num_workers
,
)
)
# Scheduler and math around the number of training steps.
# Scheduler and math around the number of training steps.
...
...
examples/textual_inversion/textual_inversion.py
View file @
6fedb29f
...
@@ -194,6 +194,14 @@ def parse_args():
...
@@ -194,6 +194,14 @@ def parse_args():
parser
.
add_argument
(
parser
.
add_argument
(
"--lr_warmup_steps"
,
type
=
int
,
default
=
500
,
help
=
"Number of steps for the warmup in the lr scheduler."
"--lr_warmup_steps"
,
type
=
int
,
default
=
500
,
help
=
"Number of steps for the warmup in the lr scheduler."
)
)
parser
.
add_argument
(
"--dataloader_num_workers"
,
type
=
int
,
default
=
0
,
help
=
(
"Number of subprocesses to use for data loading. 0 means that the data will be loaded in the main process."
),
)
parser
.
add_argument
(
"--adam_beta1"
,
type
=
float
,
default
=
0.9
,
help
=
"The beta1 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_beta1"
,
type
=
float
,
default
=
0.9
,
help
=
"The beta1 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_beta2"
,
type
=
float
,
default
=
0.999
,
help
=
"The beta2 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_beta2"
,
type
=
float
,
default
=
0.999
,
help
=
"The beta2 parameter for the Adam optimizer."
)
parser
.
add_argument
(
"--adam_weight_decay"
,
type
=
float
,
default
=
1e-2
,
help
=
"Weight decay to use."
)
parser
.
add_argument
(
"--adam_weight_decay"
,
type
=
float
,
default
=
1e-2
,
help
=
"Weight decay to use."
)
...
@@ -566,7 +574,9 @@ def main():
...
@@ -566,7 +574,9 @@ def main():
center_crop
=
args
.
center_crop
,
center_crop
=
args
.
center_crop
,
set
=
"train"
,
set
=
"train"
,
)
)
train_dataloader
=
torch
.
utils
.
data
.
DataLoader
(
train_dataset
,
batch_size
=
args
.
train_batch_size
,
shuffle
=
True
)
train_dataloader
=
torch
.
utils
.
data
.
DataLoader
(
train_dataset
,
batch_size
=
args
.
train_batch_size
,
shuffle
=
True
,
num_workers
=
args
.
dataloader_num_workers
)
# Scheduler and math around the number of training steps.
# Scheduler and math around the number of training steps.
overrode_max_train_steps
=
False
overrode_max_train_steps
=
False
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment