Spaces:
Running
Running
Allen Park
commited on
Commit
·
17a12ac
1
Parent(s):
4dd4e1f
change to dynamic device
Browse files
app.py
CHANGED
@@ -5,7 +5,10 @@ import gradio as gr
|
|
5 |
import spaces
|
6 |
|
7 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
8 |
-
|
|
|
|
|
|
|
9 |
|
10 |
tokenizer = AutoTokenizer.from_pretrained("PatronusAI/Llama-3-Patronus-Lynx-8B-Instruct")
|
11 |
model = AutoModelForCausalLM.from_pretrained("PatronusAI/Llama-3-Patronus-Lynx-8B-Instruct", torch_dtype=torch.float16, device_map="auto")
|
|
|
5 |
import spaces
|
6 |
|
7 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
8 |
+
if torch.cuda.is_available():
|
9 |
+
device = "cuda:0"
|
10 |
+
else:
|
11 |
+
device = "cpu"
|
12 |
|
13 |
tokenizer = AutoTokenizer.from_pretrained("PatronusAI/Llama-3-Patronus-Lynx-8B-Instruct")
|
14 |
model = AutoModelForCausalLM.from_pretrained("PatronusAI/Llama-3-Patronus-Lynx-8B-Instruct", torch_dtype=torch.float16, device_map="auto")
|