Refuse to start with more GPUs than MAX_GPU_COUNT - #16
Merged
ricky-chaoju merged 1 commit intoSep 2, 2026
Merged
Conversation
daemon_loop (src/main.c prev_managed[MAX_GPU_COUNT]) and the dashboard (src/dashboard.c gpus[MAX_GPU_COUNT], init_mode[MAX_GPU_COUNT][16], init_speed[MAX_GPU_COUNT]) keep per-GPU state in arrays sized by MAX_GPU_COUNT (8) but indexed by device_count, so a host with nine or more GPUs overran them. Fail at gpu_init with a message naming the limit and the constant to raise instead.
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.
Small one.
daemon_loopkeepsprev_managed[MAX_GPU_COUNT]and the dashboard keepsgpus[MAX_GPU_COUNT],init_mode[MAX_GPU_COUNT][16]andinit_speed[MAX_GPU_COUNT], but they're all indexed bydevice_count(orst->gpu_count, which is set from it).MAX_GPU_COUNTis 8, so on a host with nine or more GPUs those arrays get written past the end.I don't have such a box, so this just makes
gpu_initfail with a message naming the count, the limit and the constant to raise, rather than silently clamping — clamping would leave the extra GPUs under driver control while the daemon and dashboard report success, which seems worse than a clear refusal. The error path callsnvmlShutdown()before returning, same as the existingnvmlDeviceGetCountfailure path just above it.