Spaces:
Paused
Paused
Tonic commited on
Commit ·
d283050
1
Parent(s): cd87fec
move all model and components to cuda
Browse files
app.py
CHANGED
|
@@ -370,12 +370,19 @@ def make_prediction(symbol: str, timeframe: str = "1d", prediction_days: int = 5
|
|
| 370 |
# Move model to evaluation mode
|
| 371 |
pipe.model.eval()
|
| 372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
# Use predict_quantiles with proper formatting
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
|
|
|
| 379 |
|
| 380 |
if quantiles is None or mean is None:
|
| 381 |
raise ValueError("Chronos returned empty prediction")
|
|
|
|
| 370 |
# Move model to evaluation mode
|
| 371 |
pipe.model.eval()
|
| 372 |
|
| 373 |
+
# Ensure pipeline components are on the correct device
|
| 374 |
+
if hasattr(pipe, 'tokenizer'):
|
| 375 |
+
pipe.tokenizer = pipe.tokenizer.to(device)
|
| 376 |
+
if hasattr(pipe, 'config'):
|
| 377 |
+
pipe.config = pipe.config.to(device)
|
| 378 |
+
|
| 379 |
# Use predict_quantiles with proper formatting
|
| 380 |
+
with torch.cuda.device(device):
|
| 381 |
+
quantiles, mean = pipe.predict_quantiles(
|
| 382 |
+
context=context,
|
| 383 |
+
prediction_length=actual_prediction_length,
|
| 384 |
+
quantile_levels=[0.1, 0.5, 0.9]
|
| 385 |
+
)
|
| 386 |
|
| 387 |
if quantiles is None or mean is None:
|
| 388 |
raise ValueError("Chronos returned empty prediction")
|