7 lines
177 B
Python
Raw Normal View History

2025-01-27 20:01:02 +01:00
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tensor = torch.randn(3, 3).to(device) # Moves the tensor to GPU
print(tensor)
print(device)