Tonic commited on
Commit
ebe7c27
·
1 Parent(s): 6616ba7

readd ZeroGPU cuda model loading

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -51,7 +51,7 @@ def clear_gpu_memory():
51
  torch.cuda.empty_cache()
52
  gc.collect()
53
 
54
- # @spaces.GPU(duration=180)
55
  def load_pipeline():
56
  """Load the Chronos model with GPU configuration"""
57
  global pipeline
@@ -69,6 +69,8 @@ def load_pipeline():
69
  )
70
  # Set model to evaluation mode
71
  pipeline.model = pipeline.model.eval()
 
 
72
  # Disable gradient computation
73
  for param in pipeline.model.parameters():
74
  param.requires_grad = False
@@ -366,6 +368,11 @@ def make_prediction(symbol: str, timeframe: str = "1d", prediction_days: int = 5
366
  pipe.model.eval()
367
  pipe.model = pipe.model.to(device)
368
 
 
 
 
 
 
369
  # Use predict_quantiles with proper formatting
370
  quantiles, mean = pipe.predict_quantiles(
371
  context=context,
 
51
  torch.cuda.empty_cache()
52
  gc.collect()
53
 
54
+ @spaces.GPU(duration=180)
55
  def load_pipeline():
56
  """Load the Chronos model with GPU configuration"""
57
  global pipeline
 
69
  )
70
  # Set model to evaluation mode
71
  pipeline.model = pipeline.model.eval()
72
+ # Move entire model to CUDA
73
+ pipeline.model = pipeline.model.cuda()
74
  # Disable gradient computation
75
  for param in pipeline.model.parameters():
76
  param.requires_grad = False
 
368
  pipe.model.eval()
369
  pipe.model = pipe.model.to(device)
370
 
371
+ # Ensure all model components are on the same device
372
+ for module in pipe.model.modules():
373
+ if hasattr(module, 'to'):
374
+ module.to(device)
375
+
376
  # Use predict_quantiles with proper formatting
377
  quantiles, mean = pipe.predict_quantiles(
378
  context=context,