Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,8 @@ class LinearModel(torch.nn.Module):
|
|
16 |
return out
|
17 |
|
18 |
|
19 |
-
def process():
|
|
|
20 |
print('cuda avaliable: ' + str(torch.cuda.is_available()))
|
21 |
print('cuda device count: ' + str(torch.cuda.device_count()))
|
22 |
|
@@ -31,19 +32,19 @@ def process():
|
|
31 |
|
32 |
@spaces.GPU
|
33 |
def greet(n):
|
34 |
-
process()
|
35 |
return f"Hello {n} Tensor"
|
36 |
|
37 |
|
38 |
def func(n):
|
39 |
# step1, on cpu
|
40 |
-
process()
|
41 |
|
42 |
# step2, on gpu
|
43 |
res = greet(n)
|
44 |
|
45 |
# step3, on cpu
|
46 |
-
process()
|
47 |
|
48 |
return res
|
49 |
|
|
|
16 |
return out
|
17 |
|
18 |
|
19 |
+
def process(n: int):
|
20 |
+
print(f'\n===process step {n}')
|
21 |
print('cuda avaliable: ' + str(torch.cuda.is_available()))
|
22 |
print('cuda device count: ' + str(torch.cuda.device_count()))
|
23 |
|
|
|
32 |
|
33 |
@spaces.GPU
|
34 |
def greet(n):
|
35 |
+
process(2)
|
36 |
return f"Hello {n} Tensor"
|
37 |
|
38 |
|
39 |
def func(n):
|
40 |
# step1, on cpu
|
41 |
+
process(1)
|
42 |
|
43 |
# step2, on gpu
|
44 |
res = greet(n)
|
45 |
|
46 |
# step3, on cpu
|
47 |
+
process(3)
|
48 |
|
49 |
return res
|
50 |
|