User Tools

Site Tools


examples

This is an old revision of the document!


  1. PyTorch Example:
import torch
 
def test_pytorch():
    print("PyTorch version:", torch.__version__)
    print("CUDA available:", torch.cuda.is_available())
 
    if torch.cuda.is_available():
        print("CUDA device:", torch.cuda.get_device_name(0))
        device = torch.device("cuda")
    else:
        device = torch.device("cpu")
 
    # Simple tensor operation
    x = torch.tensor([1.0, 2.0, 3.0], device=device)
    y = torch.tensor([4.0, 5.0, 6.0], device=device)
    z = x + y
    print("Tensor operation result:", z)
 
test_pytorch()
examples.1743458214.txt.gz · Last modified: 2025/03/31 21:56 by nshegunov

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki