Monitor GPU usage, occupy it when usage is below the threshold.
监视gpu使用率,低于阈值就占满,防止被kill
占卡脚本,监控 GPU 利用率,并在 GPU 利用率低于指定阈值时计算,防止利用率不足被kill。
- Python 3.x
- NVIDIA GPU 和驱动
- PyTorch
nvidia-ml-py3库(安装命令:pip install nvidia-ml-py3)
- 安装所需库:
pip install torch nvidia-ml-py3
- 运行脚本: nohup python3 fuck_gpu.py
A script for occupying GPUs: Monitors GPU utilization and performs computations when GPU utilization is below a specified threshold to prevent being killed due to insufficient utilization.
- Continuously monitors GPU usage using NVIDIA's NVML library.
- Automatically starts dummy matrix multiplication tasks on GPUs with low utilization.
- Stops dummy tasks when utilization rises above the specified threshold.
- Supports multi-GPU systems.
- Uses PyTorch for GPU computation tasks.
- Python 3.x
- NVIDIA GPU and drivers
- PyTorch
nvidia-ml-py3library (install usingpip install nvidia-ml-py3)
- The script initializes NVML to monitor GPU utilization.
- It checks the utilization of each GPU at regular intervals.
- If a GPU's utilization is below the threshold (default: 60%), it starts a dummy task that performs matrix multiplications on that GPU.
- If the utilization exceeds the threshold, the dummy task is stopped.
- Install the required libraries:
pip install torch nvidia-ml-py3
- Run the script: nohup python3 fuck_gpu.py