art-of-debugging

Systematically debug Unix, Python, and PyTorch crashes, hangs, segfaults, OOMs, and wrong outputs using tools like strace, py-spy, and gdb.

1.7k|106|Updated Oct 1, 2023
One-click install
npx skills add https://github.com/stas00/the-art-of-debugging --skill art-of-debugging
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: art-of-debugging
Source: https://github.com/stas00/the-art-of-debugging/tree/main
Command: npx skills add https://github.com/stas00/the-art-of-debugging --skill art-of-debugging

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gdb, strace, py-spy, torch, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill helps debug Unix, Python, and PyTorch programs quickly and effectively, addressing crashes, hangs, segfaults, OOM, and more.

Core Features & Use Cases

  • Unix Tools: Utilize tools like bash, strace, make, nohup, etc., for efficient Unix debugging.
  • Python Debugging: Apply advanced techniques for Python debugging, including effective printing, ensuring code runs from source, and using profilers like cProfile and line_profiler.
  • PyTorch Debugging: Address CUDA OOM, NaN/Inf, slow performance, and multi-GPU issues in PyTorch programs.
  • Use Case: When a Python program hangs or a PyTorch model produces incorrect results, use this Skill to diagnose and resolve the issue.

Quick Start

Use the 'art-of-debugging' skill to debug a Python hang by running 'py-spy dump -n -p <PID>' to analyze the Python subprocess.

Frequently Asked Questions about art-of-debugging

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

FAQPage Schema
How do I debug a Python program that hangs?

To debug a hanging Python program, use py-spy to dump the stack trace of the process, such as running `py-spy dump -n -p <PID>` to analyze the subprocess and identify the blocking call.

How do I resolve CUDA out of memory errors in PyTorch?

Resolve CUDA out of memory errors in PyTorch by applying systematic debugging methodologies to diagnose memory leaks, profile tensor allocations, and address multi-GPU issues.

What is the best way to trace system calls when debugging a Unix crash?

The best way to trace system calls during a Unix crash is using strace to monitor program execution, alongside other Unix tools like bash and make to systematically isolate the fault.

How do I find NaN or Inf values in a PyTorch model?

Find NaN or Inf values in a PyTorch model by applying targeted PyTorch debugging techniques to trace incorrect outputs back to their source operations and validate gradient computations.

Can I use gdb to debug segfaults in Python extensions?

Yes, you can use gdb to debug segfaults in Python extensions, as it is a required dependency for systematically diagnosing crashes and low-level memory issues in Python programs.

How do I profile slow Python code performance?

Profile slow Python code performance using profilers like cProfile and line_profiler to identify execution bottlenecks, measure function timing, and optimize the overall throughput.