Repository navigation
Inject NVIDIA MPS env vars and pipe mount into MPS containers - #5082
Merged
Merged
Conversation
amogh09
approved these changes
Aug 3, 2026
harishxr
enabled auto-merge (rebase)
August 3, 2026 22:24
prateekchaudhry
approved these changes
Aug 3, 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.
Summary
Injects the NVIDIA MPS per-client environment variables and the MPS control-pipe mount into MPS containers, so the limits parsed from a container's GPU sharingStrategy are actually applied at container launch.
A prior change parses a container's ACS GPU sharingStrategy into
container.MPSConfig, but nothing yet acts on it. This wires that config through to the container: the MPS server can now enforce each container's memory and compute ceiling.Implementation details
For any container with MPSConfig set
container.UsesMPS():populateGPUEnvironmentVariablesalongside the existingNVIDIA_VISIBLE_DEVICES, the container receives:dockerHostConfig: a bind mount of the control-pipe directory/tmp/nvidia-mpsis added. The NVIDIA container runtime's CDI spec injects only the MPS binaries, not the pipe directory, so without this mount the injected memory limit is silently unenforced (the runtime finds no pipe and runs without MPS).Both hooks are gated on
UsesMPS(), so whole-GPU and non-GPU containers are untouched.The env-var names, the 0=M formatting, and the omit-when-undeclared rule live in a new shared package
ecs-agent/utils/mpsTesting
Built a custom agent from this change and installed it on a AL2023 GPU AMI and ran some tasks carrying MPS limits (the payload was driven via a test-only mock, since the backend sharingStrategy path is not yet shipped). docker inspect confirmed the expected
CUDA_MPS_*env vars (with compute omitted when undeclared) and the pipe-directory bind mount on MPS containers, and their absence on non-MPS containers. A workload with the memory limit set below the physical GPU memory was capped at the injected ceiling rather than the physical total, confirming the injected value is enforced.New tests cover the changes: yes
Description for the changelog
Enhancement - Inject NVIDIA MPS env vars and pipe mount into MPS containers
Additional Information
**Does this PR include breaking model changes? If so, Have you added transformation functions?**No
Does this PR include the addition of new environment variables in the README? No
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.