fix(build): cap default build parallelism by available memory to prevent OOM - #8873
Merged
mc-nv merged 2 commits intoJul 8, 2026
Conversation
mc-nv
marked this pull request as ready for review
July 8, 2026 16:36
…allelism-to-avoid-runner-ooms
whoisj
approved these changes
Jul 8, 2026
| # Honor CPU affinity / cgroup pinning where available (Linux); fall back to | ||
| # the logical core count on platforms without sched_getaffinity. | ||
| try: | ||
| return len(os.sched_getaffinity(0)) |
mc-nv
deleted the
mchornyi/TRI-1550/cap-tritonserver-build-parallelism-to-avoid-runner-ooms
branch
July 8, 2026 21:05
mc-nv
added a commit
that referenced
this pull request
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?
Caps the default
build.pyparallelism so fully-uncached builds no longer OOM theGitLab runner hosts.
Previously the default was
multiprocessing.cpu_count() * 2, which has two problems forTriton's memory-heavy C++/CUDA compilation (including the nested ONNX Runtime build):
multiprocessing.cpu_count()reports the host's logical core count — it ignores CPUaffinity and cgroup quotas, so a constrained build on a large host could spawn far more
jobs than intended.
2 * coresoversubscribes memory on swap-less builders and the OOM killer terminatesrunner/system daemons instead of the build, leaving jobs stuck or orphaned.
The default is now computed by
default_build_parallel(), which:os.sched_getaffinity(0)(respects pinning/cgroups), fallingback to
multiprocessing.cpu_count()on non-Linux platforms;-jso each compile job has ~2 GB of RAM headroom, based onMemAvailablefrom/proc/meminfo;Passing
-j/--build-parallelexplicitly is unaffected — only the default changes.Checklist
<commit_type>: <Title>Commit Type:
Related PRs:
triton-inference-server/onnxruntime_backend#348
Where should the reviewer start?
build.py— the newusable_cpu_count(),available_memory_gb(), anddefault_build_parallel()helpers, and thedefault_build_parallel()call at theFLAGS.build_parallel is Nonedefault site.Test plan:
Simulated the parallelism calculation across representative host profiles:
/proc/meminfo→ CPU-only fallback (usable_cpu_count())python3 -c "import ast; ast.parse(open('build.py').read())"passes.Validate on the affected
builder/arm-builderjobs that a fully uncached buildno longer OOMs the runner.
CI Pipeline ID: 57283463
Caveats:
spike higher. Tunable in-source if needed.
--enable-all) path the default is computed on the host and baked intothe generated build scripts; if a build container is constrained with
--memory, thehost's
MemAvailablewon't reflect that cap. Can be extended to read the cgroupmemory.maxinside the build stage if CI constrains container memory.os.sched_getaffinityis Linux-only (hence themultiprocessing.cpu_count()fallback).Background
GitLab build jobs were failing with logs abruptly stopping because runner hosts OOM'd
during fully uncached builds — unbounded parallelism in the Tritonserver build (including
the nested ONNX Runtime build) on swap-less builders.
Related Issues: