Skip to main content

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 彩色表格、纯文本模式按需切换
  • 启动时自动探测不可连接主机,单独列出并跳过后续刷新

快速开始

  1. 确保本地 Python ≥ 3.9 且可运行 ssh
  2. 主机上必须安装 nvidia-smi(NVIDIA 驱动自带),并已配置免密登录
  3. 在源码目录或安装后运行:
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 的可视化体验,可根据需要安装 richtextual

# Textual 模式(默认,建议同时安装 rich + textual)
pip install rich textual
remo-gpu --interval 2

# Rich 彩色表格
pip install rich
remo-gpu --ui rich --interval 2
  • 默认 textual:可滚动卡片(依赖 rich+textual),支持 ↑/↓、rq
  • rich:彩色表格+进度条;
  • plain:纯文本输出,便于记录日志。

使用 uvx 运行

借助 uvuvx 子命令,可以在隔离环境中运行脚本而不手动创建虚拟环境:

# 在项目根目录
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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

remo_gpu-0.1.2.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

remo_gpu-0.1.2-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file remo_gpu-0.1.2.tar.gz.

File metadata

  • Download URL: remo_gpu-0.1.2.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for remo_gpu-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2d2f6bc73fe5fc03c746785e750a16608ec683ab49bd1c13e4402ab8499ab38b
MD5 762683ef235803da42aa8266cbe02e92
BLAKE2b-256 e675def2b5ab80a9753cf1ee4b29f76f86d63f1aa775928123a484f5b3be2aa7

See more details on using hashes here.

File details

Details for the file remo_gpu-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: remo_gpu-0.1.2-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

Hashes for remo_gpu-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ffa36e845945ec80fefa70b27305a319bb2246c1abe2fddf873ff0a7925cfd60
MD5 bedd7f69db02088917fe85bc8e48e55d
BLAKE2b-256 f0148d9cedda9c537e3765fc90872fd4781ffb67a0b50ff7f18b3357bb357371

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page