Skip to content

feat: Add CDI device support#762

Merged
Junkern merged 4 commits intokreuzwerker:masterfrom
jdon:master
Apr 1, 2026
Merged

feat: Add CDI device support#762
Junkern merged 4 commits intokreuzwerker:masterfrom
jdon:master

Conversation

@jdon
Copy link
Copy Markdown
Contributor

@jdon jdon commented Jul 26, 2025

This PR allows users to use the CDI interface to pass through GPUs to their containers instead of using the existing gpus = "all".

This is needed as operating systems like nixos are removing the support for gpus all.

I wasn't sure what the best interface for this would be so I ended up just copying the devices interface from docker compose . Please let me know if you think there is a better way to support this use case.

This is my first PR to this repo, so I've done something wrong or missed something please let me know 🙏

Changes:

  • Adds CDI (Container Device Interface) device support via a new device_requests field
  • Added ConflictsWith validation between gpus and device_requests
  • Updated documentation
  • Added tests for:
    • CDI device
    • GPU
    • Conflict validation
  • Added check in tests to skip them if a NVIDIA GPU is not found.

@Junkern
Copy link
Copy Markdown
Collaborator

Junkern commented Aug 12, 2025

Edit: Rewrote my whole answer

Thanks for the PR! I looked at the implementation and the gpus is working 50%. Passing all the values to the docker host should be fine. However, reading back the values from the container is not implemented, yet.

I will see, whether we can have a quick fix for this, or whether the code from your PR needs to be merged

@Junkern
Copy link
Copy Markdown
Collaborator

Junkern commented Apr 1, 2026

Hey @jdon sorry for the long pause. I want to merge this PR as part of the next major (4.0.0) release. Do you have some time in the upcoming days to resolve conflicts/a few review comments from my side?

(In addition to this PR I will fix the gpus implementation)

@jdon
Copy link
Copy Markdown
Contributor Author

jdon commented Apr 1, 2026

Hey @Junkern,

Thanks for the ping here, I dropped the ball on this, I've just been using a fork locally for my needs 😂.

It would be great to get this merged! I've just fixed up the conflicts. Please let me know what changes you would like and I'm more than happy to make them.

(In addition to this PR I will fix the gpus implementation)

What are your plans for this? Are you planning on removing gpus and pushing everyone down the device requests route?

(Also feel free to push commits to this branch if that's quicker / easier for you!)

Comment thread internal/provider/resource_docker_container.go Outdated
@Junkern
Copy link
Copy Markdown
Collaborator

Junkern commented Apr 1, 2026

What are your plans for this? Are you planning on removing gpus and pushing everyone down the device requests route?

No, I will just improve it, so that it properly works (with all the options listed in https://docs.docker.com/reference/cli/docker/container/run/#gpus)
So that means, that you can define "GPU requests" in two ways - but I think that's okay for now. For the release after the next major release I can potentially remove gpus

Copy link
Copy Markdown
Collaborator

@Junkern Junkern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Will become part of a new 4.0.0-beta3 release in the next days and then after some testing the final release will come.
Failing test has nothing to do with your changes, just some hickups with pulling images from dockerhub (fixing this is on my list)

@Junkern Junkern merged commit 8bac991 into kreuzwerker:master Apr 1, 2026
9 of 10 checks passed
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