Skip to content

fix(build): cap ONNX Runtime build parallelism to avoid runner OOM (#348) - #349

Merged
mc-nv merged 1 commit into
r26.07from
mchornyi/TRI-1550/cp-oom
Jul 8, 2026
Merged

fix(build): cap ONNX Runtime build parallelism to avoid runner OOM (#348)#349
mc-nv merged 1 commit into
r26.07from
mchornyi/TRI-1550/cp-oom

Conversation

@mc-nv

@mc-nv mc-nv commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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 budget
capped 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:

  • Relates to: TRI-1550

)

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.
@mc-nv mc-nv added the cherry-pick Cherry-pick to a release branch label Jul 8, 2026
@mc-nv mc-nv self-assigned this Jul 8, 2026
@mc-nv
mc-nv requested review from whoisj and yinggeh July 8, 2026 21:12
@mc-nv
mc-nv marked this pull request as ready for review July 8, 2026 21:13
@mc-nv
mc-nv merged commit e28926d into r26.07 Jul 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick Cherry-pick to a release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants