feat(train): add AUTO_FREE_GPUS mode to train_multi_gpu.sh - #12
Closed
tkgstrator wants to merge 1 commit into
Closed
feat(train): add AUTO_FREE_GPUS mode to train_multi_gpu.sh#12tkgstrator wants to merge 1 commit into
tkgstrator wants to merge 1 commit into
Conversation
Automatically restrict CUDA_VISIBLE_DEVICES to GPUs with used memory below FREE_GPU_MEM_MB (default 500 MiB) when AUTO_FREE_GPUS=1. Prevents multiple training jobs from interfering on shared hardware. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Superseded by new PR with wrapped commit body. |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
scripts/train_multi_gpu.shgains two new env vars:AUTO_FREE_GPUS=1— before launching torchrun, querynvidia-smifor per-GPU memory usage and setCUDA_VISIBLE_DEVICESto the GPUs whose used memory is underFREE_GPU_MEM_MB.FREE_GPU_MEM_MB(default500) — the "free" threshold in MiB.NPROC_PER_NODEis derived from the count of surviving GPUs so torchrun uses only those.Why
The 8x A100 box is shared with other running jobs (currently GPU 0 and GPU 2 are in use). Kicking off a naive
NPROC_PER_NODE=8DDP run would OOM those GPUs or trample the neighbors. This mode picks up only the idle GPUs so multiple training jobs coexist safely on the same host.Test plan
detect_free_gpus 500on the current box returns1,3,4,5,6,7(skips busy GPU 0 and 2)AUTO_FREE_GPUS=1and confirmCUDA_VISIBLE_DEVICESis set and torchrun uses only the free 6 GPUs🤖 Generated with Claude Code