Shared Code

by operativecreative·7 views·Aug 6, 2026Open in Playground →
main.cu
12345678910111213
import torch

print(f"PyTorch version : {torch.__version__}")
print(f"CUDA available  : {torch.cuda.is_available()}")
if torch.cuda.is_available():
    print(f"GPU             : {torch.cuda.get_device_name(0)}")

# Simple tensor op on GPU
x = torch.randn(1024, 1024, device="cuda")
y = torch.randn(1024, 1024, device="cuda")
z = torch.mm(x, y)
print(f"\nMatrix multiply 1024x1024 — result shape: {z.shape}")
print(f"Result sample   : {z[0, :4].tolist()}")

Comments (0)

to post comments and vote
No comments yet. Be the first to share your thoughts!