Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import torch
|
|
| 8 |
import gradio as gr
|
| 9 |
import pandas as pd
|
| 10 |
import yfinance as yf
|
|
|
|
| 11 |
from peft import PeftModel
|
| 12 |
from collections import defaultdict
|
| 13 |
from datetime import date, datetime, timedelta
|
|
@@ -31,8 +32,11 @@ model = PeftModel.from_pretrained(
|
|
| 31 |
'FinGPT/fingpt-forecaster_dow30_llama2-7b_lora',
|
| 32 |
offload_folder="offload/"
|
| 33 |
)
|
|
|
|
| 34 |
model = model.eval()
|
| 35 |
|
|
|
|
|
|
|
| 36 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 37 |
'meta-llama/Llama-2-7b-chat-hf',
|
| 38 |
token=access_token
|
|
@@ -47,6 +51,13 @@ SYSTEM_PROMPT = "You are a seasoned stock market analyst. Your task is to list t
|
|
| 47 |
"Your answer format should be as follows:\n\n[Positive Developments]:\n1. ...\n\n[Potential Concerns]:\n1. ...\n\n[Prediction & Analysis]\nPrediction: ...\nAnalysis: ..."
|
| 48 |
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
def get_curday():
|
| 52 |
|
|
@@ -229,8 +240,8 @@ def construct_prompt(ticker, curday, n_weeks, use_basics):
|
|
| 229 |
|
| 230 |
def predict(ticker, date, n_weeks, use_basics):
|
| 231 |
|
| 232 |
-
|
| 233 |
-
|
| 234 |
info, prompt = construct_prompt(ticker, date, n_weeks, use_basics)
|
| 235 |
|
| 236 |
inputs = tokenizer(
|
|
|
|
| 8 |
import gradio as gr
|
| 9 |
import pandas as pd
|
| 10 |
import yfinance as yf
|
| 11 |
+
from pynvml import *
|
| 12 |
from peft import PeftModel
|
| 13 |
from collections import defaultdict
|
| 14 |
from datetime import date, datetime, timedelta
|
|
|
|
| 32 |
'FinGPT/fingpt-forecaster_dow30_llama2-7b_lora',
|
| 33 |
offload_folder="offload/"
|
| 34 |
)
|
| 35 |
+
model = model.half()
|
| 36 |
model = model.eval()
|
| 37 |
|
| 38 |
+
print_gpu_utilization()
|
| 39 |
+
|
| 40 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 41 |
'meta-llama/Llama-2-7b-chat-hf',
|
| 42 |
token=access_token
|
|
|
|
| 51 |
"Your answer format should be as follows:\n\n[Positive Developments]:\n1. ...\n\n[Potential Concerns]:\n1. ...\n\n[Prediction & Analysis]\nPrediction: ...\nAnalysis: ..."
|
| 52 |
|
| 53 |
|
| 54 |
+
def print_gpu_utilization():
|
| 55 |
+
|
| 56 |
+
nvmlInit()
|
| 57 |
+
handle = nvmlDeviceGetHandleByIndex(0)
|
| 58 |
+
info = nvmlDeviceGetMemoryInfo(handle)
|
| 59 |
+
print(f"GPU memory occupied: {info.used//1024**2} MB.")
|
| 60 |
+
|
| 61 |
|
| 62 |
def get_curday():
|
| 63 |
|
|
|
|
| 240 |
|
| 241 |
def predict(ticker, date, n_weeks, use_basics):
|
| 242 |
|
| 243 |
+
print_gpu_utilization()
|
| 244 |
+
|
| 245 |
info, prompt = construct_prompt(ticker, date, n_weeks, use_basics)
|
| 246 |
|
| 247 |
inputs = tokenizer(
|