Metadata-Version: 2.4
Name: whovidia
Version: 0.1.0
Summary: 一眼看清谁在霸占 GPU — a tiny Linux CLI that prints which user is using how much GPU memory.
Author: whovidia contributors
License: MIT
License-File: LICENSE
Keywords: cli,gpu,linux,monitoring,nvidia,nvidia-smi,sysadmin
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# whovidia

> 一眼看清谁在霸占 GPU。
> A tiny Linux CLI that prints which user is using how much GPU memory.

```
┌─────────┬──────────┬─────────┬─────────────────────────────────────────────┐
│   PID   │   用户   │   占用  │                    跑的啥                   │
╞═════════╪══════════╪═════════╪═════════════════════════════════════════════╡
│ 2422445 │ rui.zhao │ 17.8 GB │ reconstruction_pipeline_node（已经跑 6.0 小时）│
│ 1719272 │ root     │  5.0 GB │ carter.py（已经跑 9.5 小时）                  │
└─────────┴──────────┴─────────┴─────────────────────────────────────────────┘
```

## 安装 / Install

```bash
pip install whovidia
```

需要 Python 3.9+ 和 `nvidia-smi`（装了 NVIDIA 驱动的 **Linux**）。

Requires Python 3.9+ and `nvidia-smi` on PATH. **Linux only.** Windows is unsupported because `nvidia-smi --query-compute-apps` on Windows includes graphics processes (DWM, browsers, games) without usable memory accounting, so the table can't be trusted. macOS has no NVIDIA GPUs.

## 用法 / Usage

```bash
whovidia
```

也可以这么跑 / or run as a module:

```bash
python -m whovidia
```

输出按显存占用从大到小排序，包括：
Output is sorted by GPU memory usage (descending) and shows:

- **PID** — 进程号
- **用户 / user** — 占用 GPU 的系统用户
- **占用 / VRAM** — 显存占用 (`MB` / `GB`)
- **跑的啥 / process** — 进程命令名（自动解开 `python script.py` 这种壳），并附上已运行时长

颜色输出在 TTY 下自动启用；可设置 `NO_COLOR=1` 关闭。
ANSI colors are enabled automatically on a TTY; set `NO_COLOR=1` to disable.

## 工作原理 / How it works

1. 调用 `nvidia-smi --query-compute-apps=pid,used_memory,process_name`
   拿到所有占用 GPU 的进程；
2. 用 `ps -o user=,etimes=,args=` 补上用户名、运行时长、命令行；
3. 渲染成一张 Unicode 表格，按显存排序。

整个工具零运行时依赖 — 只用 Python 标准库。
Zero runtime dependencies — pure Python stdlib.

## License

MIT
