Fix DRM loop error propagation bypassing PCI fallback on vGPU instances#27810
Open
f-dy wants to merge 1 commit intomicrosoft:mainfrom
Open
Fix DRM loop error propagation bypassing PCI fallback on vGPU instances#27810f-dy wants to merge 1 commit intomicrosoft:mainfrom
f-dy wants to merge 1 commit intomicrosoft:mainfrom
Conversation
On AWS EC2 vGPU instances (e.g. g5.xlarge with A10G), /sys/class/drm/card0 exists (simple-framebuffer for console VGA) but lacks device/vendor. GetGpuDeviceFromSysfs fails, and ORT_RETURN_IF_ERROR propagates the error immediately, preventing the PCI fallback at line 289 from ever running. The PCI path has the correct data: /sys/bus/pci/devices/0000:00:1e.0/vendor = 0x10de (NVIDIA) /sys/bus/pci/devices/0000:00:1e.0/class = 0x030200 (3D controller) Change the DRM loop to log a warning and continue instead of returning error, as suggested by @tianleiwu during the microsoft#27591 review. This allows the loop to skip non-GPU DRM entries (like simple-framebuffer) and fall through to the PCI fallback when no valid GPU is found via DRM. Fixes microsoft#27806
edgchen1
reviewed
Mar 24, 2026
| auto drm_status = GetGpuDeviceFromSysfs(gpu_sysfs_path_info, gpu_device); | ||
| if (!drm_status.IsOK()) { | ||
| LOGS_DEFAULT(WARNING) << "Skipping DRM device at " << gpu_sysfs_path_info.path << ": " << drm_status.ErrorMessage(); | ||
| continue; |
Contributor
There was a problem hiding this comment.
if it fails part of the way into the loop (if gpu_devices.size() > 0) then it also won't get to the PCI fallback logic. is that fine?
|
|
||
| Status GetGpuDevices(std::vector<OrtHardwareDevice>& gpu_devices_out) { | ||
| std::vector<GpuSysfsPathInfo> gpu_sysfs_path_infos{}; | ||
| ORT_RETURN_IF_ERROR(DetectGpuSysfsPaths(gpu_sysfs_path_infos)); |
Contributor
There was a problem hiding this comment.
would an early return from DetectGpuSysfsPaths() also cause issues?
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Linux GPU device discovery on AWS EC2 vGPU instances where /sys/class/drm/cardN entries exist but are missing required metadata (e.g., device/vendor), by preventing a single DRM parsing failure from aborting discovery and thereby allowing the existing PCI fallback path to run.
Changes:
- Update the DRM sysfs scan loop in
GetGpuDevices()to log a warning and skip invalid DRM entries instead of returning early on error. - Preserve the existing behavior where PCI bus scanning is used when DRM-based discovery yields zero valid GPUs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Description
Fixes #27806.
On AWS EC2 vGPU instances (e.g. g5.xlarge with A10G),
/sys/class/drm/card0exists as a simple-framebuffer for console VGA but lacksdevice/vendor.GetGpuDeviceFromSysfsfails, andORT_RETURN_IF_ERRORpropagates the error immediately, preventing the PCI fallback (added in #27591) from ever running.The PCI path has the correct data:
Change
Change the DRM loop in
GetGpuDevices()to log a warning andcontinueinstead ofORT_RETURN_IF_ERROR, as suggested by @tianleiwu during the #27591 review. This allows the loop to skip non-GPU DRM entries (like simple-framebuffer) and fall through to the PCI fallback when no valid GPU is found via DRM.Before:
ORT_RETURN_IF_ERROR(GetGpuDeviceFromSysfs(gpu_sysfs_path_info, gpu_device));After:
Testing
Verified on AWS EC2 g5.xlarge (NVIDIA A10G, Ubuntu 24.04):
GetEpDevices()returns onlyCPUExecutionProvider; warning:GPU device discovery failed: Failed to open file: "/sys/class/drm/card0/device/vendor"GetEpDevices()returns bothCPUExecutionProviderandCUDAExecutionProvider; warning:Skipping DRM device at "/sys/class/drm/card0": Failed to open file: "/sys/class/drm/card0/device/vendor"(PCI fallback finds GPU correctly)Motivation and Context
This blocks the plugin EP architecture (
RegisterExecutionProviderLibrary,CopyTensors, shared allocators) on all AWS EC2 GPU instances where the vGPU driver does not expose nvidia-drm vendor metadata via sysfs.