Skip to main content

自动维持 GPU SM 利用率守护进程,防止任务被强杀

Project description

gpu-keepalive

自动维持 GPU SM 利用率 ≥ 40%,防止任务被集群强杀。
任务真正运行时自动让路,支持混卡环境(V100 / A100 / H100 / B200 …)。

安装

pip install gpu-keepalive

或从源码安装(本地开发):

git clone https://github.com/yourname/gpu-keepalive
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,30-3all
--min 40 SM 利用率低于此值时启动占位 kernel
--target 50 占位 kernel 的目标利用率
--interval 2.0 采样间隔(秒)

工作原理

  1. interval 秒查询一次各卡 SM 利用率
  2. 利用率 < --min 时,启动占位 kernel(fp16 矩阵乘法),通过 PI 控制器将利用率稳定在 --target
  3. 检测到真实负载(利用率 ≥ --min)时,立刻停止占位 kernel,彻底让路
  4. 自动识别 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


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.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

gpu_keepalive-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file gpu_keepalive-0.1.0.tar.gz.

File metadata

  • Download URL: gpu_keepalive-0.1.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for gpu_keepalive-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d1dd9de5ca737194e1b9db517f005790942915beb81e436a042c6234bf09c681
MD5 8144a4b2b4a978757928035479a8556d
BLAKE2b-256 4e96867cea1186efdf170aa475bf1ef5d659e53751812ccfa9ac511cf3f0f8cd

See more details on using hashes here.

File details

Details for the file gpu_keepalive-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gpu_keepalive-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for gpu_keepalive-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb53e869c0f28e85fa971b8bffe6019ca34d7cd789b147da706f254be37ae87f
MD5 70fe581a59af15af556c0d35c05ce8d8
BLAKE2b-256 41a53a8dc7660a3f7540f79534b0afff5e435d72ff24d01d627b51c0021b8839

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