Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pin_memory -> dataloader_pin_memory #9874

Merged
merged 2 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def get_train_dataloader(self) -> DataLoader:
collate_fn=self.data_collator,
drop_last=self.args.dataloader_drop_last,
num_workers=self.args.dataloader_num_workers,
pin_memory=self.args.pin_memory,
pin_memory=self.args.dataloader_pin_memory,
)

def _get_eval_sampler(self, eval_dataset: Dataset) -> Optional[torch.utils.data.sampler.Sampler]:
Expand Down Expand Up @@ -523,7 +523,7 @@ def get_eval_dataloader(self, eval_dataset: Optional[Dataset] = None) -> DataLoa
collate_fn=self.data_collator,
drop_last=self.args.dataloader_drop_last,
num_workers=self.args.dataloader_num_workers,
pin_memory=self.args.pin_memory,
pin_memory=self.args.dataloader_pin_memory,
)

def get_test_dataloader(self, test_dataset: Dataset) -> DataLoader:
Expand All @@ -550,7 +550,7 @@ def get_test_dataloader(self, test_dataset: Dataset) -> DataLoader:
batch_size=self.args.eval_batch_size,
collate_fn=self.data_collator,
drop_last=self.args.dataloader_drop_last,
pin_memory=self.args.pin_memory,
pin_memory=self.args.dataloader_pin_memory,
)

def create_optimizer_and_scheduler(self, num_training_steps: int):
Expand Down
6 changes: 4 additions & 2 deletions src/transformers/training_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class TrainingArguments:
When using distributed training, the value of the flag :obj:`find_unused_parameters` passed to
:obj:`DistributedDataParallel`. Will default to :obj:`False` if gradient checkpointing is used, :obj:`True`
otherwise.
pin_memory (:obj:`bool`, `optional`, defaults to :obj:`True`)):
dataloader_pin_memory (:obj:`bool`, `optional`, defaults to :obj:`True`)):
Whether you want to pin memory in data loaders or not. Will default to :obj:`True`.
"""

Expand Down Expand Up @@ -438,7 +438,9 @@ class TrainingArguments:
"`DistributedDataParallel`."
},
)
pin_memory: bool = field(default=True, metadata={"help": "Whether or not to pin memory for data loaders."})
dataloader_pin_memory: bool = field(
default=True, metadata={"help": "Whether or not to pin memory for DataLoader."}
)
_n_gpu: int = field(init=False, repr=False, default=-1)

def __post_init__(self):
Expand Down