ukumar557 commited on
Commit
ac21e0a
·
verified ·
1 Parent(s): fdaa844

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -2,11 +2,16 @@ import gradio as gr
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import torch
4
 
 
 
 
 
 
5
  # Load the tokenizer and model directly
6
  model_name = "ruslanmv/ai-medical-model-32bit"
7
  tokenizer = AutoTokenizer.from_pretrained(model_name)
8
  model = AutoModelForCausalLM.from_pretrained(model_name)
9
- model.to("cuda") # Move model to GPU
10
 
11
 
12
  # Function to ask medical questions
 
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import torch
4
 
5
+ # Check if CUDA is available
6
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
7
+ if device.type == "cpu":
8
+ print("Warning: CUDA is not available. Running on CPU, which may be slow.")
9
+
10
  # Load the tokenizer and model directly
11
  model_name = "ruslanmv/ai-medical-model-32bit"
12
  tokenizer = AutoTokenizer.from_pretrained(model_name)
13
  model = AutoModelForCausalLM.from_pretrained(model_name)
14
+
15
 
16
 
17
  # Function to ask medical questions