Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import spaces
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
zero = torch.Tensor([0]).cuda()
|
| 6 |
+
print(zero.device) # <-- 'cpu' 🤔
|
| 7 |
+
|
| 8 |
+
@spaces.GPU
|
| 9 |
+
def chat(prompt):
|
| 10 |
+
print(zero.device) # <-- 'cuda:0' 🤗
|
| 11 |
+
return f"Hello {zero + n} Tensor"
|
| 12 |
+
|
| 13 |
+
gr.Interface(
|
| 14 |
+
fn=chat,
|
| 15 |
+
inputs=gr.Text(),
|
| 16 |
+
outputs=gr.Text()
|
| 17 |
+
).launch()
|