hiascend commited on
Commit
cdab2e6
·
verified ·
1 Parent(s): 1ee0472

Update app.py

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