godweiyang/GrabGPU
一款便捷的抢占显卡脚本
What it solves
This project provides a script to occupy GPU memory and compute resources, simulating GPU usage to prevent other users or automated systems from reclaiming the GPU (often referred to as "grabbing" or "preempting" the GPU).
How it works
The tool uses CUDA C++ and Tensor Cores (WMMA 16x16x16 FP16) to create a workload that consumes a specific amount of VRAM and maintains a target GPU utilization rate. It automatically calibrates the kernel iteration time to keep it stable at approximately 50ms, ensuring that monitoring tools like nvidia-smi and DCGM report consistent metrics. When a utilization rate lower than 100% is requested, the script manages a duty cycle (alternating between active work and sleep) to accurately hit the target percentage.
Who it’s for
Developers and researchers working in shared GPU clusters where resource management systems might automatically reclaim idle GPUs.
Highlights
- High-fidelity simulation: Simulates SM Activity, SM Occupancy, and Tensor Core activity to make the usage look genuine.
- Customizable parameters: Allows users to specify the exact amount of VRAM (GB), duration of occupancy, specific GPU IDs, and target utilization rate.
- Automatic calibration: Dynamically adjusts kernel iterations to maintain stable metrics regardless of the GPU architecture.
- Integration: Can trigger a custom shell script (e.g., a model training script) once the GPU resources are successfully occupied.
Related
- Project
- Project
- Project
- Project
- Project