Skip to content

A straightforward method for training your LLM, from downloading data to generating text.

fix: robustly moving model to cuda

Tianyi (Alex) Qiuc5463472a82c
diff --git a/scripts/train_transformer.py b/scripts/train_transformer.py
index 84a0343..61c7db3 100644
--- a/scripts/train_transformer.py
+++ b/scripts/train_transformer.py
@@ -22,6 +22,9 @@ model = Transformer(
device=device,
).to(device)
+if device.type != 'cpu':
+ model = model.cuda()
+
criterion = torch.nn.CrossEntropyLoss()
def create_dataloader(split: Literal["train", "val"]) -> Iterator[Tuple[torch.Tensor, torch.Tensor]]: