Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

feat(model): add MPS support for Apple Silicon #237

Merged
merged 1 commit into from
Aug 20, 2023
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
9 changes: 7 additions & 2 deletions basaran/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ class StreamModel:

def __init__(self, model, tokenizer):
super().__init__()
self.model = model
self.tokenizer = tokenizer
self.device = "cuda" if torch.cuda.is_available() else "cpu"
if torch.backends.mps.is_available():
self.device = 'mps'
elif torch.cuda.is_available():
self.device = 'cuda'
else:
self.device = 'cpu'
self.model = model.to(self.device)

def __call__(
self,
Expand Down