Repository navigation
Report per-GPU memory at container instance registration - #5061
Conversation
c6c8dc3 to
5fb5ba5
Compare
ecs-init discovers per-GPU usable memory via NVML and the agent reports it in the PlatformDevice.gpuInfo field so the control plane can place GPU instances by available memory.
5fb5ba5 to
cb88dff
Compare
| Type: types.PlatformDeviceTypeGpu, | ||
| }) | ||
| } | ||
| if memMiB, ok := n.GPUMemoryMiB[gpuID]; ok { |
There was a problem hiding this comment.
What is the case when memory could be missing?
There was a problem hiding this comment.
Potential cases:
- NVML does not return a response due to some reason when we query for memory, memory will be missing in such a case.
- Agent version is newer than init version, ecs-init will not be able to write the gpuMemory to the gpu info file where agent reads from. In that case, memory will be empty as well.
| seelog.Errorf("Failed to get UUID for device at index %d during memory detection: %v", i, nvml.ErrorString(ret)) | ||
| continue |
There was a problem hiding this comment.
We should think about how we can better surface such errors to customers. Silently registering less capacity is not ideal.
There was a problem hiding this comment.
Can this mismatch be caught in DescribeContainerInstances response vs EC2 DescribeInstances or something like that?
| seelog.Errorf("Unexpected v2 memory for device %s: total %d < reserved %d; skipping", uuid, mem.Total, mem.Reserved) | ||
| continue | ||
| } | ||
| memory[uuid] = (mem.Total - mem.Reserved) / bytesPerMiB |
There was a problem hiding this comment.
Q: In the case of a zero value here, what would the agent's behavior be here? (e.g. would we still advertise ecs.capability.gpu-sharing-mps?). Also got a similar question with Amogh on how users can discover this on their own.
There was a problem hiding this comment.
Agent reporting zero value, would not gate the capability from being advertised. For the second part, discussed offline
| // a workload can actually allocate under MPS. | ||
| func (n *NvidiaGPUManager) DetectGPUMemory() map[string]uint64 { | ||
| memory := make(map[string]uint64) | ||
| count, err := NvmlGetDeviceCount() |
There was a problem hiding this comment.
We should not need this, as we have already done a GetGPUDeviceIDs which populates n.GPUIDs. We can just iterate over those UUIDs as source of truth and get the needed device handles. Minor simplification.
There was a problem hiding this comment.
Or we can combine both methods too
There was a problem hiding this comment.
Good suggestion, will look into this as a follow up
Summary
ecs-init discovers per-GPU usable memory (NVML v2 Total - Reserved) during Setup and persists it as a UUID->MiB map in the GPU info file. The agent loads the map and populates PlatformDevice.GpuInfo.MemoryInMiB when building
the RegisterContainerInstance payload, so the control plane can size GPUs for MPS memory-based placement.
Implementation details
Backward compatible and additive: the field is omitempty on both sides, so older agents/hosts that do not report it send nothing, and the control plane treats it as optional.
Testing
nvidia-gpu-info.jsonGPUMemoryMiB = 22563, matching nvidia-smi (23034 total - 471 reserved).New tests cover the changes: yes
Description for the changelog
Enhancement - Report per-GPU memory at container instance registration for GPU sharing
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.