Skip to content

Add GPU passthrough support#15

Merged
neil-cresswell-portainer merged 1 commit intoportainer:developfrom
adelorenzo-portainer:feat/gpu-support
Apr 13, 2026
Merged

Add GPU passthrough support#15
neil-cresswell-portainer merged 1 commit intoportainer:developfrom
adelorenzo-portainer:feat/gpu-support

Conversation

@adelorenzo-portainer
Copy link
Copy Markdown
Contributor

Summary

  • Parse Docker's --gpus flag (HostConfig.DeviceRequests) and translate it into Kubernetes device plugin resource limits on the pod spec
  • New D2K_GPU_RESOURCE_NAME env var controls which resource name to use (e.g. amd.com/gpu, nvidia.com/gpu)
  • When unset, GPU requests are silently ignored (backward compatible)

Changes

  • internal/config/config.go — new D2K_GPU_RESOURCE_NAME config option
  • internal/adapter/adapter.go — thread GPU resource name into adapter
  • internal/api/containers/containers.go — parse DeviceRequests from Docker API body
  • internal/adapter/container.go — add GPU resource limits to pod spec in buildDeployment()

Test plan

  • Deployed on minikube with AMD GPU device plugin (2x RX 7900 XTX)
  • docker run --gpus all via d2k → pod gets amd.com/gpu: 1 in resource limits
  • Container sees /dev/kfd and /dev/dri/renderD128
  • Without --gpus flag, no resource limits set (backward compatible)
  • go build and go test pass

🤖 Generated with Claude Code

Parse Docker's --gpus flag (HostConfig.DeviceRequests) and translate it
into Kubernetes device plugin resource limits (e.g. amd.com/gpu or
nvidia.com/gpu) on the pod spec. Controlled by D2K_GPU_RESOURCE_NAME
env var — when unset, GPU requests are silently ignored (backward
compatible).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@neil-cresswell-portainer neil-cresswell-portainer merged commit c922483 into portainer:develop Apr 13, 2026
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.

2 participants