Mohamad-Jaallouk commited on
Commit
45aefee
1 Parent(s): 9b15cf2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -6,13 +6,14 @@ import torch
6
 
7
 
8
  class ModelProcessor:
 
9
  def __init__(self, repo_id="HuggingFaceTB/cosmo-1b"):
10
  # Initialize the tokenizer
11
  self.tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=True)
12
 
13
  # Initialize and configure the model
14
  self.model = AutoModelForCausalLM.from_pretrained(
15
- repo_id, torch_dtype=torch.float16, device_map="cpu", trust_remote_code=True
16
  )
17
  self.model.eval() # Set the model to evaluation mode
18
 
 
6
 
7
 
8
  class ModelProcessor:
9
+ device = "cuda:0" if torch.cuda.is_available() else "cpu"
10
  def __init__(self, repo_id="HuggingFaceTB/cosmo-1b"):
11
  # Initialize the tokenizer
12
  self.tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=True)
13
 
14
  # Initialize and configure the model
15
  self.model = AutoModelForCausalLM.from_pretrained(
16
+ repo_id, torch_dtype=torch.float16, device_map={"": device}, trust_remote_code=True
17
  )
18
  self.model.eval() # Set the model to evaluation mode
19