lamekemal commited on
Commit
2bbbd42
·
verified ·
1 Parent(s): 513cce0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -16,11 +16,14 @@ def load_model():
16
  tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
17
  model = AutoModelForCausalLM.from_pretrained(
18
  model_name,
19
- device_map="auto",
20
  torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
21
  trust_remote_code=True,
22
  )
23
- pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, device=0 if torch.cuda.is_available() else -1)
 
 
 
24
  return pipe
25
 
26
  # On charge le pipeline une fois au démarrage
 
16
  tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
17
  model = AutoModelForCausalLM.from_pretrained(
18
  model_name,
19
+ device_map="auto", # Accelerate gère la répartition CPU/GPU
20
  torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
21
  trust_remote_code=True,
22
  )
23
+
24
+ # Ne PAS passer device quand on utilise accelerate
25
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
26
+
27
  return pipe
28
 
29
  # On charge le pipeline une fois au démarrage