ecc-pytorch-build-resolver

Diagnose and fix local PyTorch tensor shape, device, autograd, and CUDA errors.

Updated Apr 18, 2025
One-click install
npx skills add https://github.com/adriancodes/dotfiles --skill ecc-pytorch-build-resolver-adriancodes
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ecc-pytorch-build-resolver
Source: https://github.com/adriancodes/dotfiles/tree/main/dot_agents/skills/ecc-pytorch-build-resolver
Command: npx skills add https://github.com/adriancodes/dotfiles --skill ecc-pytorch-build-resolver-adriancodes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? PyTorch training and inference code frequently fails with cryptic runtime errors such as tensor shape mismatches, CPU/GPU device conflicts, broken autograd graphs, and CUDA out-of-memory conditions. This Skill provides a structured diagnostic workflow to resolve these reported local errors with minimal, surgical code changes. ## Core Features & Use Cases - Error Pattern Resolution: Maps common PyTorch tracebacks (shape mismatches, device placement, in-place autograd violations, DataLoader collation errors) to concrete fixes. - Bounded Local Diagnostics: Uses existing environment checks like torch version queries, nvidia-smi, and targeted shape/memory print statements without installing packages or launching training jobs. - Use Case: A user reports RuntimeError: mat1 and mat2 shapes cannot be multiplied in train.py. The Skill traces tensor shapes, identifies the mismatched nn.Linear layer, corrects in_features, and verifies the fix with a bounded local reproducer. ## Quick Start Diagnose and fix the PyTorch RuntimeError reported in my train.py traceback using minimal changes.

Frequently Asked Questions about ecc-pytorch-build-resolver

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix PyTorch tensor shape mismatch errors?▼

Trace tensor shapes by printing shape, dtype, and device before the failing line, then align layer dimensions. For 'mat1 and mat2 shapes cannot be multiplied', fix the nn.Linear in_features to match the previous layer's output size.

How to resolve 'Expected all tensors to be on the same device' in PyTorch?▼

This error means some tensors are on CPU while the model or other tensors are on GPU. Apply .to(device) consistently to the model and all input tensors so every operand in the computation shares one device.

Why does PyTorch throw CUDA out of memory errors?▼

CUDA OOM comes from oversized live tensors, retained autograd graphs, large batches, or fragmentation. Inspect live allocations with torch.cuda.memory_summary in the failing process, release unintended references, and consider gradient checkpointing rather than relying on cache clearing.

Can this Skill install packages or update CUDA drivers?▼

No. It works only within the existing local environment and explicitly avoids package installs, driver changes, training launches, and model downloads. Missing prerequisites like drivers or GPUs are reported rather than worked around.

What causes 'one of the variables needed for gradient computation has been modified by an inplace operation'?▼

An in-place operation such as x += 1 or in-place ReLU overwrote a tensor needed by autograd. Replace in-place ops with out-of-place equivalents like x = x + 1 so the computation graph stays intact.

When should I stop attempting PyTorch error fixes?▼

Stop and report if the same error persists after three fix attempts, the fix requires fundamental architecture changes, the cause is hardware or driver incompatibility, or OOM persists even at batch_size=1.