Skip to content

Instantly share code, notes, and snippets.

@brando90
Created November 22, 2024 22:08
Show Gist options
  • Save brando90/bb3b86cd968d93b3dd79db671a68859f to your computer and use it in GitHub Desktop.
Save brando90/bb3b86cd968d93b3dd79db671a68859f to your computer and use it in GitHub Desktop.
import torch
# Create two matrices on the GPU
matrix_a = torch.rand((1000, 1000), device='cuda')
matrix_b = torch.rand((1000, 1000), device='cuda')
# Perform matrix sum
result = matrix_a + matrix_b
# Verify and print device of the result
print(f"Result is on device: {result.device}")
print(f"First element of result: {result[0, 0]}")
@brando90
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment