bharatcoder commited on
Commit
88de128
·
verified ·
1 Parent(s): 57fd750

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -3
app.py CHANGED
@@ -6,10 +6,8 @@ zero = torch.Tensor([0]).cuda()
6
  print(f"Outside function: {zero.device}") # Should print 'cuda:0'
7
 
8
  # Define the function to greet and perform a tensor operation on the GPU
 
9
  def greet(n):
10
- # Make sure the tensor is on the same device
11
- zero_gpu = zero.to('cuda') # This ensures the tensor is on the GPU
12
- print(f"Inside function: {zero_gpu.device}") # Should print 'cuda:0'
13
  result = zero_gpu + torch.Tensor([n]).cuda() # Perform operation on GPU
14
  return f"Hello, result: {result.item()}"
15
 
 
6
  print(f"Outside function: {zero.device}") # Should print 'cuda:0'
7
 
8
  # Define the function to greet and perform a tensor operation on the GPU
9
+ @spaces.GPU
10
  def greet(n):
 
 
 
11
  result = zero_gpu + torch.Tensor([n]).cuda() # Perform operation on GPU
12
  return f"Hello, result: {result.item()}"
13