Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
-
import spaces
|
3 |
import torch
|
4 |
|
5 |
-
spaces.zero.torch.unpatch()
|
6 |
|
7 |
-
|
8 |
-
|
9 |
|
10 |
-
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
15 |
|
|
|
16 |
|
17 |
-
def print_device():
|
18 |
print('zero device: ' + str(zero.device))
|
19 |
print('one device: ' + str(one.device))
|
20 |
print('two device: ' + str(two.device))
|
21 |
|
22 |
-
|
23 |
-
print_device()
|
24 |
-
|
25 |
-
|
26 |
-
@spaces.GPU
|
27 |
-
def greet(n):
|
28 |
-
print('greeting')
|
29 |
-
print_device()
|
30 |
return f"Hello {zero + n} Tensor"
|
31 |
|
32 |
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import torch
|
3 |
|
|
|
4 |
|
5 |
+
def greet(n):
|
6 |
+
print('cuda avaliable: ' + str(torch.cuda.is_available()))
|
7 |
|
8 |
+
torch.set_default_device('cuda')
|
9 |
|
10 |
+
zero = torch.Tensor([0]).cuda()
|
11 |
|
12 |
+
one = torch.ones(2, 2, device='cuda')
|
13 |
|
14 |
+
two = torch.matmul(one, one).cuda()
|
15 |
|
|
|
16 |
print('zero device: ' + str(zero.device))
|
17 |
print('one device: ' + str(one.device))
|
18 |
print('two device: ' + str(two.device))
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
return f"Hello {zero + n} Tensor"
|
21 |
|
22 |
|