自动维持 GPU SM 利用率守护进程,防止任务被强杀
Project description
gpu-keepalive
自动维持 GPU SM 利用率 ≥ 40%,防止任务被集群强杀。
任务真正运行时自动让路,支持混卡环境(V100 / A100 / H100 / B200 …)。
安装
pip install gpu-keepalive
或直接从 Git 仓库安装:
pip install "git+https://github.com/mmmwhy/gpu-keepalive.git"
本地开发:
git clone https://github.com/mmmwhy/gpu-keepalive.git
cd gpu_keepalive
pip install -e .
快速使用
# 守护所有 GPU,默认阈值 40%
gpu_keepalive go
# 只守护 GPU 0 和 1
gpu_keepalive go --gpus 0,1
# 守护 GPU 0~3,自定义阈值
gpu_keepalive go --gpus 0-3 --min 40 --target 50
# 查看当前各卡利用率
gpu_keepalive status
# 列出系统所有 GPU 信息
gpu_keepalive list
参数说明
| 参数 | 默认 | 说明 |
|---|---|---|
--gpus |
all |
GPU 编号,支持 0,1,3、0-3、all |
--min |
40 |
SM 利用率低于此值时启动占位 kernel |
--target |
50 |
占位 kernel 的目标利用率 |
--interval |
2.0 |
采样间隔(秒) |
工作原理
- 每
interval秒查询一次各卡 SM 利用率 - 利用率 <
--min时,启动占位 kernel(fp16 矩阵乘法),通过 PI 控制器将利用率稳定在--target - 检测到真实负载(利用率 ≥
--min)时,立刻停止占位 kernel,彻底让路 - 自动识别 GPU 型号,按 V100 / H100 / B200 等选择合适的矩阵规模
依赖
- Python ≥ 3.10
- PyTorch ≥ 2.0(需要 CUDA 版本)
- pynvml ≥ 11.0
推荐使用方式
# 放入 tmux / screen,挂在后台
tmux new -s keepalive
gpu_keepalive go --gpus all
# Ctrl-B D 分离,自由 debug
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
gpu_keepalive-0.1.1.tar.gz
(7.6 kB
view details)
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 gpu_keepalive-0.1.1.tar.gz.
File metadata
- Download URL: gpu_keepalive-0.1.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3059e34ca48137f81e6ebf463dceba5868f2e591d2a835dcc22025dbe07e693
|
|
| MD5 |
f4230be151fbf81a215c151946548450
|
|
| BLAKE2b-256 |
2b54ecbfeef43242ab21856809bb617e148d411a7076c2f17fc1a2c72d352b81
|
File details
Details for the file gpu_keepalive-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gpu_keepalive-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0dc6563e398687e931ff24e1adbce9e6ad66edb28bf035c53202d26d866cda1
|
|
| MD5 |
f267c04b6db86f809797c37b18c40c36
|
|
| BLAKE2b-256 |
9504de2780a745d932d788ec2bb5ed592373c3dbc2bfa16e5517890af14725fb
|