Skip to content

Commit

Permalink
feat: Add low cpu by default (#40)
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <cegao@tensorchord.ai>
  • Loading branch information
gaocegege authored May 25, 2023
1 parent 0f68f8a commit 59e2524
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/modelz_llm/falcon_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ class LLM:
def __init__(self, model_name: str, device: str) -> None:
self.model_name = model_name
self.tokenizer = transformers.AutoTokenizer.from_pretrained(
model_name, trust_remote_code=True
model_name, trust_remote_code=True, low_cpu_mem_usage=True
)
model_cls = getattr(transformers, LanguageModels.transformer_cls(model_name))
self.model = model_cls.from_pretrained(model_name, trust_remote_code=True)
self.model = model_cls.from_pretrained(
model_name, trust_remote_code=True, low_cpu_mem_usage=True
)
if device == "auto":
self.device = (
torch.cuda.current_device() if torch.cuda.is_available() else "cpu"
Expand Down

0 comments on commit 59e2524

Please sign in to comment.