hiascend commited on
Commit
5326ed4
·
verified ·
1 Parent(s): e89c6d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
2
  import spaces
3
  import torch
4
 
 
 
5
  zero = torch.Tensor([0]).cuda()
6
 
7
  one = torch.ones(2, 2, device='cuda')
@@ -11,6 +13,7 @@ two = torch.matmul(one, one).cuda()
11
 
12
  def print_device():
13
  print('cuda avaliable: ' + str(torch.cuda.is_available()))
 
14
  print('zero device: ' + str(zero.device))
15
  print('one device: ' + str(one.device))
16
  print('two device: ' + str(two.device))
 
2
  import spaces
3
  import torch
4
 
5
+ torch.set_default_device('cuda')
6
+
7
  zero = torch.Tensor([0]).cuda()
8
 
9
  one = torch.ones(2, 2, device='cuda')
 
13
 
14
  def print_device():
15
  print('cuda avaliable: ' + str(torch.cuda.is_available()))
16
+ print('default device: ' + str(torch.get_default_device()))
17
  print('zero device: ' + str(zero.device))
18
  print('one device: ' + str(one.device))
19
  print('two device: ' + str(two.device))