py-spy-tui
A Rust terminal UI for py-spy, packaged so users can install it with:
pip install py-spy-tui
py-spy-tui
py-spy-tui depends on the py-spy Python package, so installing the TUI also installs
the profiler binary on supported platforms.
Current Features
- Groups Python processes by distributed training metadata, process tree, runtime prefix, working directory, and command fingerprint.
- Detects virtualenv, uv-managed Python, Conda, pyenv, and system runtimes.
- Shows PyTorch rank metadata when process environment is readable.
- Explains Linux rootless profiling setup before asking sudo to attach to a process.
- Uses
sudo -vfor authentication and never reads or stores a password.
Usage
py-spy-tui
Non-interactive checks:
py-spy-tui --help
py-spy-tui --version
Keys:
Enter: record the selected process or process group for 30 seconds.d: runpy-spy dumpfor the selected process or process group.r: refresh process groups.Space: expand or collapse a group.j/kor arrow keys: move selection.PageUp/PageDown: scroll output.q: quit.
When a group is selected, py-spy-tui runs one py-spy command per process. This is useful
for torchrun and distributed PyTorch training, where ranks are often sibling processes
rather than children of a single attach target.
Reports
Every record run creates a recognizable report folder in the current directory:
py-spy-report-<target-name>-<unix-timestamp>/
raw/
pid-1234.svg
pid-1235.svg
report.md
report.json
The raw/ folder keeps py-spy's original SVG records. report.md is written for humans,
and report.json is structured so you can pass the folder to an LLM and ask it to compare
hot frames, rank imbalance, blocking stacks, and data-loading stalls.
Linux Rootless Profiling
Attaching to an existing process often requires elevated permissions on Linux. To allow same-user profiling without sudo:
sudo sysctl kernel.yama.ptrace_scope=0
To keep that setting after reboot:
echo 'kernel.yama.ptrace_scope=0' | sudo tee /etc/sysctl.d/10-py-spy-tui.conf
sudo sysctl --system
This changes system-wide ptrace policy for same-user debugging. Use sudo from the TUI when you prefer not to change the host setting.
Build
Local full check:
just build-all
That runs formatting, tests, clippy, clears dist/, builds a wheel, and smoke-checks it.
Build a local wheel:
uv build --wheel
Linux release wheels should be built as musllinux so they do not require the target machine's glibc version:
just dist-linux-x86_64-musl
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_spy_tui-0.1.1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: py_spy_tui-0.1.1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 551.7 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4216737b8de0616cc904c1d119f05d62208f5e914ffde250a4e9a1aae33043ee
|
|
| MD5 |
a3b03fe95d0774c96d3edf32c9602d32
|
|
| BLAKE2b-256 |
d943f709c98525144bdd53e41dce7fd970f7916907764e6d75b07f36613303cf
|