Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
| 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
|