Monitor GPUs on every SSH host defined in ~/.ssh/config.
Project description
Remo-GPU
一个基于 Python 的命令行工具,用于批量监控 ~/.ssh/config 中所有主机的 GPU 使用情况。脚本会对每台主机执行一次 nvidia-smi(或自定义命令),并以表格形式实时刷新结果。发布到 PyPI 后即可:
pip install remo-gpu
remo-gpu --interval 3
特性
- 自动解析
~/.ssh/config及其Include指令,获取可用主机别名 - 并发执行 SSH 命令,默认最多 8 台同时查询
- Textual 卡片式 UI 默认启用,可滚动查看所有主机
- Rich 彩色表格、纯文本模式按需切换
- 启动时自动探测不可连接主机,单独列出并跳过后续刷新
快速开始
- 确保本地 Python ≥ 3.9 且可运行
ssh - 主机上必须安装
nvidia-smi(NVIDIA 驱动自带),并已配置免密登录 - 在源码目录或安装后运行:
python3 -m remo_gpu --interval 3
# 或使用安装后的 CLI
remo-gpu --interval 3
默认每 5 秒刷新一次,可按 Ctrl + C 退出。
常用参数
python3 -m remo_gpu \
--interval 3 \
--timeout 8 \
--hosts gpu-a gpu-b \
--identity-file ~/.ssh/id_rsa \
--ssh-option "-o StrictHostKeyChecking=no" \
--ssh-option "-o UserKnownHostsFile=/dev/null"
--hosts: 仅监控指定 Host 别名--interval: 刷新间隔(秒),默认 5--timeout: 单次 SSH 命令超时(秒),默认 10--identity-file: 指定私钥文件,等价于ssh -i--ssh-option: 其他 SSH 原始参数,可多次传入--remote-command: 自定义远程查询命令,默认执行nvidia-smi--interval-once: 只运行一次后退出--no-clear: 禁用清屏,便于查看更长的输出历史
Rich / Textual UI(可选)
如需更接近 nvitop 的可视化体验,可根据需要安装 rich 或 textual:
# Textual 模式(默认,建议同时安装 rich + textual)
pip install rich textual
remo-gpu --interval 2
# Rich 彩色表格
pip install rich
remo-gpu --ui rich --interval 2
- 默认
textual:可滚动卡片(依赖 rich+textual),支持 ↑/↓、r、q; rich:彩色表格+进度条;plain:纯文本输出,便于记录日志。
使用 uvx 运行
借助 uv 的 uvx 子命令,可以在隔离环境中运行脚本而不手动创建虚拟环境:
# 在项目根目录
uvx --from . remo-gpu --interval 3 --ui plain
# 若需 Rich UI,可顺便拉取依赖
uvx --from . --with rich remo-gpu --ui rich --interval 2
# Textual UI(需 rich + textual)
uvx --from . --with rich --with textual remo-gpu --ui textual
uvx --from . 会使用当前目录作为包来源;通过 --with rich/textual 可以在隔离环境中临时安装对应可选依赖。其余 CLI 参数与直接调用 python3 -m remo_gpu 完全一致。
Bash 版本
如果希望以纯 bash 方式运行,可直接执行 remo_gpu.sh:
bash remo_gpu.sh \
--interval 3 \
--hosts gpu-a,gpu-b \
--ssh-option StrictHostKeyChecking=no \
--ssh-option UserKnownHostsFile=/dev/null
--ssh-option会被转换为ssh -o key=value--once仅输出一次结果- 兼容 macOS 自带 bash 3.2;若已安装 bash 4+,同样可直接运行
提示
- 如
.ssh/config使用了通配符(Host *),脚本会自动忽略 - 若首次连接提示主机指纹,可通过
--ssh-option "-o StrictHostKeyChecking=no"关闭严格校验(按需使用) - 对监控频率要求更高时,适当调小
--interval并增大--concurrency
贡献
欢迎根据自身环境扩展输出格式、Prometheus 上报、或结合 watch/tmux 等工具打造个性化监控面板。*** End Patch
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 remo_gpu-0.1.1.tar.gz.
File metadata
- Download URL: remo_gpu-0.1.1.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
178a5a0669cba8be3a31f60f23ed48e76e92e071a8d085620a339a43f68c8e18
|
|
| MD5 |
067ef1a16dc901101fe2084cee54119d
|
|
| BLAKE2b-256 |
144155aa8f3b6318481f65485b3ac2d0cdbe6f93a9343ea57aed168247b8549b
|
File details
Details for the file remo_gpu-0.1.1-py3-none-any.whl.
File metadata
- Download URL: remo_gpu-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cde1c154023ef746a674b10380af2db50fc07481475d49dd2b2b60d6596ba39f
|
|
| MD5 |
c0ff39444a3d1b824c8428469d173853
|
|
| BLAKE2b-256 |
4790835d378061879333baa237159d60dbfecf4200203ea678b88eee7cecab10
|