fix(build): cap ONNX Runtime build parallelism to avoid runner OOM (#348) - #349
Merged
Conversation
) The generated Dockerfile passed a bare `--parallel` to ONNX Runtime's build.sh, which expands to multiprocessing.cpu_count(). Combined with per-nvcc multi-arch compilation, fully-uncached builds exhausted memory on swap-less builders and the OOM killer terminated runner/system daemons instead of the build. Compute the parallelism in Python at Dockerfile-generation time and bake literal `--parallel <jobs> --nvcc_threads 2` into the build step: - usable_cpu_count() honors CPU affinity/cgroup pinning (Linux), falling back to cpu_count() elsewhere. - available_memory_gb() reads MemAvailable from /proc/meminfo. - build_parallelism() budgets ~2 GB of RAM per concurrent compiler slot and bounds the product `parallel_jobs * nvcc_threads` by that budget. - The assumed budget is capped at MAX_BUILD_MEMORY_GB (64 GB): never plan for more than that, nor for more than is actually available; assume the cap when memory is unknown. Baking literals keeps the build stage free of shell logic, so it is portable across the Debian (apt) and RHEL (dnf) base-image paths. Relates to TRI-1550.
yinggeh
approved these changes
Jul 8, 2026
whoisj
approved these changes
Jul 8, 2026
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 does the PR do?
Cherry-pick of #348 to r26.07.
Caps ONNX Runtime build parallelism in the generated Dockerfile (bare
--parallel→Python-computed
--parallel <jobs> --nvcc_threads 2, bounded by a ~2 GB/slot memory budgetcapped at 64 GB) so the nested ORT build no longer OOMs swap-less runners. No functional
differences from the original; clean cherry-pick.
Related PRs:
triton-inference-server/server#8875
Related Issues: