Spaces:
Paused
Paused
Tonic commited on
Commit ·
df524ae
1
Parent(s): 2c138aa
move all model and components to cuda
Browse files
app.py
CHANGED
|
@@ -352,26 +352,11 @@ def make_prediction(symbol: str, timeframe: str = "1d", prediction_days: int = 5
|
|
| 352 |
# Move model to evaluation mode
|
| 353 |
pipe.model.eval()
|
| 354 |
|
| 355 |
-
# Move the
|
| 356 |
-
|
| 357 |
-
pipe.model.encoder = pipe.model.encoder.to(device)
|
| 358 |
-
if hasattr(pipe.model, 'decoder'):
|
| 359 |
-
pipe.model.decoder = pipe.model.decoder.to(device)
|
| 360 |
-
if hasattr(pipe.model, 'embed_tokens'):
|
| 361 |
-
pipe.model.embed_tokens = pipe.model.embed_tokens.to(device)
|
| 362 |
-
if hasattr(pipe.model, 'final_layer_norm'):
|
| 363 |
-
pipe.model.final_layer_norm = pipe.model.final_layer_norm.to(device)
|
| 364 |
-
|
| 365 |
-
# Move all parameters and buffers except distribution head
|
| 366 |
-
for name, param in pipe.model.named_parameters():
|
| 367 |
-
if 'distribution_head' not in name:
|
| 368 |
-
param.data = param.data.to(device)
|
| 369 |
-
for name, buffer in pipe.model.named_buffers():
|
| 370 |
-
if 'distribution_head' not in name:
|
| 371 |
-
buffer.data = buffer.data.to(device)
|
| 372 |
|
| 373 |
# Use predict_quantiles with proper formatting
|
| 374 |
-
with torch.
|
| 375 |
quantiles, mean = pipe.predict_quantiles(
|
| 376 |
context=context,
|
| 377 |
prediction_length=actual_prediction_length,
|
|
|
|
| 352 |
# Move model to evaluation mode
|
| 353 |
pipe.model.eval()
|
| 354 |
|
| 355 |
+
# Move the entire model to GPU
|
| 356 |
+
pipe.model = pipe.model.to(device)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
|
| 358 |
# Use predict_quantiles with proper formatting
|
| 359 |
+
with torch.amp.autocast('cuda'):
|
| 360 |
quantiles, mean = pipe.predict_quantiles(
|
| 361 |
context=context,
|
| 362 |
prediction_length=actual_prediction_length,
|