A GPU leak detection and auto-fix system for CI environments using Docker containers.
sglang-ghostbuster is an automated monitoring system that detects RDMA/MLX health failures and idle GPU memory leaks in CI environments, then automatically recovers the executor. It checks RDMA devices from a short-lived healthcheck container, treats active CI GPU memory usage as normal, and reboots when RDMA health fails or when high GPU memory remains while the runner is idle.
- Idle GPU Leak Detection: Checks GPU memory only when no CI job is active
- Active CI Awareness: Treats GPU memory usage during a running CI job as expected workload memory, not a leak
- Memory Monitoring: Uses nvidia-smi to monitor VRAM usage with CSV output
- RDMA/MLX Health Check: Starts a short-lived container from the CI image, verifies expected host InfiniBand devices with ibverbs, and performs lightweight Mooncake RDMA initialization and GPU tensor transfer checks
- Automatic Recovery: Performs system reboot when RDMA health fails or idle GPU memory exceeds the threshold
- Comprehensive Logging: Detailed logging of all operations and decisions
- Systemd Integration: Runs as a systemd timer service for reliable scheduling
- RDMA Script Dispatch: Calls the standalone
/usr/local/bin/sgl-rdma-healthcheck.shscript when RDMA checking is enabled, including while CI jobs are running - RDMA Host Check: Verifies expected
/sys/class/infinibanddevices are present and active - RDMA Container Check: Starts a short-lived container from the running CI image, copies standalone check scripts into it, and verifies
/dev/infiniband, optional in-container ibverbs CLI output, Mooncake package availability, MooncakeTransferEngine.initialize(..., "rdma", RDMA_EXPECTED_DEVICES), and a tiny CUDA tensor transfer through Mooncake - Active CI Check: Reads runner container logs and classifies runner state as
active,idle, orunknown. If Docker state cannot be read or recent logs do not contain a clear runner state, the result isunknown. - Idle GPU Memory Check: If runner state is explicitly
idle, captures current GPU memory usage withnvidia-smi - Leak Decision: If idle total GPU memory exceeds
GPU_LEAK_THRESHOLD, treats it as leaked memory - Recovery Action: Reboots system if RDMA health fails or idle GPU memory exceeds the threshold. No GPU processes are killed first.
GPU_LEAK_THRESHOLD: 51200 - VRAM usage threshold in MiB (50GB)LOG_LINES: 200 - Number of runner log lines used to detect active CI stateRDMA_HEALTHCHECK_ENABLED:1- Enable RDMA/MLX healthcheck before GPU leak handlingRDMA_HEALTHCHECK_SCRIPT:/usr/local/bin/sgl-rdma-healthcheck.sh- Standalone RDMA/Mooncake healthcheck script called by the main guardRDMA_CI_CONTAINER_NAME:sgl-ci-v2- Running CI container used to resolve the healthcheck imageRDMA_EXPECTED_DEVICES:mlx5_1,mlx5_2,mlx5_3,mlx5_4- Devices expected to be active for H20 CIRDMA_HEALTHCHECK_TIMEOUT:90- Timeout in seconds for the healthcheck containerRDMA_MOONCAKE_IMPORT_CHECK:1- Verify the Mooncake package andtransfer_engine_benchexist in the CI imageRDMA_MOONCAKE_INIT_CHECK:1- Initialize Mooncake's transfer engine in the healthcheck container withRDMA_EXPECTED_DEVICESRDMA_MOONCAKE_TENSOR_TRANSFER_CHECK:1- Transfer and verify a tiny CUDA tensor through Mooncake between two local processes in the healthcheck containerRDMA_TENSOR_CUDA_DEVICE:0- CUDA device used for the tiny tensor transfer checkRDMA_TENSOR_NUM_BYTES:1024- Size of the CUDA tensor transfer payloadGHOSTBUSTER_DRY_RUN:0- Log reboot decisions without executing reboot when set to1MAX_DAILY_REBOOTS:6- Daily reboot safety limit
/var/log/sgl-ghostbuster/guard.log- Main operation log/var/log/sgl-ghostbuster/rdma_healthcheck_*.log- RDMA container healthcheck output/var/log/sgl-ghostbuster/nvidia_current.txt- GPU state captured during idle GPU leak checks/var/log/sgl-ghostbuster/reboot_count_YYYY-MM-DD.txt- Daily reboot counter
- Linux system with systemd
- Docker installed and running
- NVIDIA GPU with nvidia-smi available
- Root privileges for installation
# Clone or download the project
cd sgl-ghostbuster
# Install and enable the service
make install enable# Copy files to system locations
sudo cp sgl-ghostbuster.sh /usr/local/bin/
sudo cp sgl-rdma-healthcheck.sh /usr/local/bin/
sudo mkdir -p /usr/local/lib/sgl-ghostbuster
sudo cp sgl-rdma-container-check.sh /usr/local/lib/sgl-ghostbuster/
sudo cp sgl-rdma-mooncake-import-check.py /usr/local/lib/sgl-ghostbuster/
sudo cp sgl-rdma-mooncake-init-check.py /usr/local/lib/sgl-ghostbuster/
sudo cp sgl-rdma-mooncake-tensor-transfer-check.py /usr/local/lib/sgl-ghostbuster/
sudo cp sgl-ghostbuster.service /etc/systemd/system/
sudo cp sgl-ghostbuster.timer /etc/systemd/system/
# Set permissions
sudo chmod 755 /usr/local/bin/sgl-ghostbuster.sh
sudo chmod 755 /usr/local/bin/sgl-rdma-healthcheck.sh
sudo chmod 755 /usr/local/lib/sgl-ghostbuster/sgl-rdma-container-check.sh
# Reload systemd and enable
sudo systemctl daemon-reload
sudo systemctl enable --now sgl-ghostbuster.timer# Install and enable service
make install enable
# Check status and logs
make status
make logs
# Manual execution
make run
# Disable service
make disable
# Uninstall completely
make uninstall
# Clean logs
make clean
# Restart service (debug)
make reload# Check timer status
systemctl status sgl-ghostbuster.timer
# View recent logs
tail -f /var/log/sgl-ghostbuster/guard.log
# Manual execution
systemctl start sgl-ghostbuster.service
# Disable timer
systemctl disable --now sgl-ghostbuster.timerThe system provides comprehensive logging:
- RDMA Health: Host and healthcheck-container RDMA/Mooncake status
- Active CI State: Whether runner logs show an active job
- GPU Status: Idle GPU memory usage from
nvidia-smi - Decision Process: Why reboots are or aren't triggered
RDMA host device mlx5_1 state='4: ACTIVE' rate='400 Gb/sec (4X NDR)'Starting RDMA healthcheck container ...RDMA container check passedMooncake tensor transfer check passed: bytes=1024 cuda_device=0 devices=...RDMA healthcheck failedActive CI job detected; GPU memory use is expected, skipping GPU leak checkCI runner state is unknown; skipping GPU leak check to avoid rebooting an active jobNo active CI job detected; checking GPU memory usage for leaksCurrent total VRAM usage: XMiBGPU memory leak detected while no CI job is active; rebooting hostNo idle GPU memory leak detected
-
Service not running
systemctl status sgl-ghostbuster.timer systemctl enable --now sgl-ghostbuster.timer -
Permission denied
sudo chmod 755 /usr/local/bin/sgl-ghostbuster.sh
-
nvidia-smi not found
- Ensure NVIDIA drivers are installed
- Check PATH includes nvidia-smi location
-
Docker containers not detected
- Verify Docker is running:
docker ps - Check container log paths are accessible
- Verify Docker is running:
-
RDMA healthcheck fails
- Check host devices:
ibv_devices,ibv_devinfo,rdma link - Check expected device list:
RDMA_EXPECTED_DEVICES - Check container output:
tail -n 100 /var/log/sgl-ghostbuster/rdma_healthcheck_*.log - Check that
/usr/local/bin/sgl-rdma-healthcheck.shexists and is executable - Check that the CI container named by
RDMA_CI_CONTAINER_NAMEexists so the healthcheck image can be resolved - Run the standalone check directly:
/usr/local/bin/sgl-rdma-healthcheck.sh - Run the full guard in dry-run mode first:
GHOSTBUSTER_DRY_RUN=1 /usr/local/bin/sgl-ghostbuster.sh
- Check host devices:
# Run manually with verbose output
sudo /usr/local/bin/sgl-ghostbuster.sh
# Run only RDMA/Mooncake healthcheck
sudo /usr/local/bin/sgl-rdma-healthcheck.sh
# Check systemd logs
journalctl -u sgl-ghostbuster.service -f- Active CI Protection: Skips GPU memory leak classification while a CI job is active or when runner state cannot be determined
- Threshold Protection: Reboots for GPU memory only when idle total VRAM usage exceeds 50GB
- RDMA Device Scope: Checks only
RDMA_EXPECTED_DEVICES, so inactive management or unused devices do not trigger reboot - RDMA Fail-Closed: Missing RDMA script, missing Docker, or unresolved CI image fails the healthcheck instead of silently passing
- RDMA Fatal Recovery: RDMA healthcheck still runs during active CI; RDMA failure triggers reboot immediately
- Daily Reboot Limit: Stops rebooting after
MAX_DAILY_REBOOTS - No Process Killing: Does not attempt
kill -9; leak recovery is reboot-only - Logging: Complete audit trail of all actions
- Graceful Degradation: Continues operation even if some commands fail
sgl-ghostbuster/
├── sgl-ghostbuster.sh # Main script
├── sgl-rdma-healthcheck.sh # Host-side standalone RDMA/Mooncake healthcheck
├── sgl-rdma-container-check.sh # Container-side RDMA check entrypoint
├── sgl-rdma-mooncake-import-check.py
├── sgl-rdma-mooncake-init-check.py
├── sgl-rdma-mooncake-tensor-transfer-check.py
├── sgl-ghostbuster.service # Systemd service file
├── sgl-ghostbuster.timer # Systemd timer file
├── Makefile # Build and management commands
└── README.md # This file
This project is part of the sglang-ghostbuster system for automated GPU leak detection and recovery in CI environments.
For issues or questions:
- Check the logs:
make logs - Verify service status:
make status - Review configuration parameters in the script
- Check system prerequisites (Docker, NVIDIA drivers, systemd)