nyuuzyou commited on
Commit
e325c4e
·
verified ·
1 Parent(s): 16ddfbb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -13,12 +13,14 @@ DEFAULT_MAX_NEW_TOKENS = 512
13
  MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "8192"))
14
 
15
  if not torch.cuda.is_available():
16
- DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
 
 
17
 
18
- if torch.cuda.is_available():
19
- model_id = "utter-project/EuroLLM-9B-Instruct"
20
- tokenizer = AutoTokenizer.from_pretrained(model_id)
21
- model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
22
 
23
  @spaces.GPU(duration=30)
24
  def generate(
@@ -121,4 +123,4 @@ with gr.Blocks(css="style.css") as demo:
121
  chat_interface.render()
122
 
123
  if __name__ == "__main__":
124
- demo.queue(max_size=20).launch()
 
13
  MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "8192"))
14
 
15
  if not torch.cuda.is_available():
16
+ print("❌ CUDA GPU not available. This demo requires a GPU to function properly.")
17
+ print("Please run this application on a system with CUDA-compatible GPU.")
18
+ exit(1)
19
 
20
+ # Load model and tokenizer
21
+ model_id = "utter-project/EuroLLM-9B-Instruct"
22
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
23
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
24
 
25
  @spaces.GPU(duration=30)
26
  def generate(
 
123
  chat_interface.render()
124
 
125
  if __name__ == "__main__":
126
+ demo.queue(max_size=20).launch()