Aliazimi00 commited on
Commit
4384e91
·
1 Parent(s): 72fac4e

Zero GPU fixes

Browse files
core/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (143 Bytes). View file
 
core/__pycache__/data.cpython-312.pyc ADDED
Binary file (20.2 kB). View file
 
core/__pycache__/train_eval.cpython-312.pyc ADDED
Binary file (21.3 kB). View file
 
core/train_eval.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import numpy as np
2
  import pandas as pd
3
  import torch
@@ -122,6 +123,7 @@ def select_features(df, features, target, selector_method, importance_threshold)
122
  logging.warning(f"Unsupported selector_method: {selector_method}, using all features")
123
  return features
124
 
 
125
  def train_and_evaluate(
126
  df,
127
  features,
@@ -141,10 +143,13 @@ def train_and_evaluate(
141
  selector_method="RandomForest",
142
  importance_threshold=0.0,
143
  scheduler_type="None",
144
- device='cpu',
145
  verbose=True
146
  ):
147
  try:
 
 
 
148
  logging.info(f"Starting train_and_evaluate: model={model_cls.__name__}, features={len(features)}, window={window}, horizon={horizon}, scheduler={scheduler_type}, selector_method={selector_method}")
149
  from .data import preprocess_data
150
 
 
1
+ import spaces
2
  import numpy as np
3
  import pandas as pd
4
  import torch
 
123
  logging.warning(f"Unsupported selector_method: {selector_method}, using all features")
124
  return features
125
 
126
+ @spaces.GPU(duration=60) # Adjust duration as needed
127
  def train_and_evaluate(
128
  df,
129
  features,
 
143
  selector_method="RandomForest",
144
  importance_threshold=0.0,
145
  scheduler_type="None",
146
+ device=None,
147
  verbose=True
148
  ):
149
  try:
150
+ # Ensure device is set to cuda if available
151
+ if device is None:
152
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
153
  logging.info(f"Starting train_and_evaluate: model={model_cls.__name__}, features={len(features)}, window={window}, horizon={horizon}, scheduler={scheduler_type}, selector_method={selector_method}")
154
  from .data import preprocess_data
155
 
packages.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ libta-lib0
2
+ lib0
push_changes.sh ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ cd /home/ubuntu/MarketPredictPro
3
+ git add .
4
+ git commit -m "Revise for Zero GPU compatibility: add spaces decorator, requirements, and packages.txt"
5
+ git push origin main
requirements.txt CHANGED
@@ -17,4 +17,5 @@ alpha_vantage
17
  textblob
18
  xgboost
19
  torchviz
20
- graphviz
 
 
17
  textblob
18
  xgboost
19
  torchviz
20
+ graphviz
21
+ spaces
test_startup.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import os
3
+
4
+ # Add the current directory to sys.path
5
+ sys.path.append(os.getcwd())
6
+
7
+ try:
8
+ print("Testing imports...")
9
+ import gradio as gr
10
+ import torch
11
+ import spaces
12
+ import talib
13
+ from core.data import load_data
14
+ from core.train_eval import train_and_evaluate
15
+ print("Imports successful!")
16
+
17
+ print("Verifying Zero GPU decorator...")
18
+ # Check if train_and_evaluate has the spaces decorator
19
+ if hasattr(train_and_evaluate, "__wrapped__"):
20
+ print("Zero GPU decorator detected on train_and_evaluate.")
21
+ else:
22
+ print("Warning: Zero GPU decorator NOT detected on train_and_evaluate.")
23
+
24
+ print("Startup test passed!")
25
+ sys.exit(0)
26
+ except Exception as e:
27
+ print(f"Startup test failed with error: {e}")
28
+ import traceback
29
+ traceback.print_exc()
30
+ sys.exit(1)