Skip to content
Merged
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
10 changes: 5 additions & 5 deletions Intro101/train_bert.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def train(
num_iterations: int = 10000,
checkpoint_every: int = 1000,
log_every: int = 10,
device: int = -1,
local_rank: int = -1,
) -> pathlib.Path:
"""Trains a [Bert style](https://arxiv.org/pdf/1810.04805.pdf)
(transformer encoder only) model for MLM Task
Expand Down Expand Up @@ -625,16 +625,16 @@ def train(
Defaults to 1000.
log_every (int, optional):
Print logs after these many steps. Defaults to 10.
device (int, optional):
local_rank (int, optional):
Which GPU to run on (-1 for CPU). Defaults to -1.

Returns:
pathlib.Path: The final experiment directory

"""
device = (
torch.device("cuda", device)
if (device > -1) and torch.cuda.is_available()
torch.device("cuda", local_rank)
if (local_rank > -1) and torch.cuda.is_available()
else torch.device("cpu")
)
################################
Expand Down Expand Up @@ -787,4 +787,4 @@ def train(


if __name__ == "__main__":
fire.Fire({"train": train, "data": create_data_iterator, "model": create_model})
fire.Fire(train)