Skip to content

fix: return a repeated visible device once - #2108

Open
lenamonj wants to merge 1 commit into
NVIDIA:mainfrom
lenamonj:visible-devices-repeated-id
Open

lenamonj wants to merge 1 commit into
NVIDIA:mainfrom
lenamonj:visible-devices-repeated-id

Conversation

@lenamonj

Copy link
Copy Markdown

Description

A device id repeated in the visible devices request, for example NVIDIA_VISIBLE_DEVICES=0,0 or the same GPU in both DOCKER_RESOURCE_GPUS and DOCKER_RESOURCE_GPUS_ADDITIONAL, puts an empty string in VisibleDevices.List(). In cdi mode container creation then fails with unresolvable CDI devices nvidia.com/gpu=none.

newDevices advanced its index for every id while the lookup map kept one entry per distinct id. It now skips an id it has already indexed, so each device is listed once, in first-seen order.

Checklist

  • No secrets, sensitive information, or unrelated changes
  • Unit tests passing (make test)
  • Lint checks passing (make lint)
  • Test cases are added for new code paths
  • Commits are signed-off and cryptographically signed

Testing

Two cases added to TestGetDevicesFromEnvvar; both fail on main and pass with the change. Also ran nvidia-container-runtime create in cdi mode against a fixture CDI spec and a stub runc on a host without a GPU: NVIDIA_VISIBLE_DEVICES=0,0 fails on main and succeeds with the change.

newDevices advanced its index for every id while the lookup map kept
one entry per distinct id, so List returned an empty string in the
slot a repeated id left behind. In cdi mode the empty entry became a
request for nvidia.com/gpu=none and the container failed to start.

Signed-off-by: Jeff Lenamon <jlenamon@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Sep 20, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant