Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
|