Skip to content
Open
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: 10 additions & 0 deletions aitextgen/aitextgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def __init__(
cache_dir: str = "aitextgen",
tf_gpt2: str = None,
to_gpu: bool = False,
to_gpu_mps: bool = False,
to_fp16: bool = False,
verbose: bool = False,
gradient_checkpointing: bool = False,
Expand Down Expand Up @@ -841,6 +842,15 @@ def to_gpu(self, index: int = 0) -> None:

self.model.to(torch.device("cuda", index))


def to_gpu_mps(self, index: int = 0) -> None:
"""Moves the model to the specified GPU."""

assert torch.backends.mps.is_available(), "MPS is not installed."

self.model.to(torch.device("mps", index))


def to_cpu(self, index: int = 0) -> None:
"""Moves the model to the specified CPU."""

Expand Down