import torch import torch.nn as nn # Explicitly detect and assign the cluster's GPU device device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') print(f"Target runtime device assigned: {device}") if device.type == 'cuda': print(f"Active GPU Hardware: {torch.cuda.get_device_name(0)}") else: print("WARNING: CUDA is not active. The script is falling back to CPU compute paths.") # Define a minimal linear transformation model model = nn.Sequential( nn.Linear(10, 50), nn.ReLU(), nn.Linear(50, 2) ).to(device) print("Neural network layer architecture moved onto device memory.") # Generate arbitrary mock tensor parameters directly on the device inputs = torch.randn(32, 10).to(device) print(f"Input batch tensor shape: {inputs.shape}") # Execute forward processing pass outputs = model(inputs) print(f"Forward computation completed. Output matrix shape: {outputs.shape}") # Simple validation calculation assertion loss = outputs.sum() print(f"Verification tracking metric: {loss.item():.4f}") print("PyTorch model diagnostics ran successfully!")