[Fix][Operator] Add privileged mode and nvidia runtime for GPU visibility#2749
[Fix][Operator] Add privileged mode and nvidia runtime for GPU visibility#2749ApostaC merged 14 commits intoLMCache:devfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces changes to the LMCache operator to enable LMCache pods to access all GPUs on a node without consuming GPU resources through the Kubernetes device plugin. This is critical for scenarios requiring CUDA IPC and custom data transfer kernels while ensuring that serving engines like vLLM can still claim and utilize the GPUs. The implementation involves setting the NVIDIA container runtime, enabling privileged mode for the pods, and configuring specific NVIDIA environment variables, with corresponding updates to the project's documentation regarding these new requirements and their security considerations. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds support for running LMCache pods with GPU visibility without consuming GPU resources from the Kubernetes device plugin. This is achieved by setting runtimeClassName: nvidia, privileged: true, and the necessary NVIDIA environment variables on the DaemonSet pods. The changes are well-implemented and correctly apply the required settings to the pod specification. The documentation in DESIGN.md and README.md has been updated accordingly to reflect these new requirements and their security implications, which is a great addition for users. I have one minor suggestion to improve code conciseness in daemonset.go.
| nvidiaRuntime := "nvidia" | ||
| privileged := true |
There was a problem hiding this comment.
These local variables are only used to get pointers to a string and a boolean. To make the code more concise, you could use a helper function. Since you are already using Go generics in your tests (ptr[T any]), you could move that helper to a shared package (e.g., internal/resources/helpers.go) and use it directly at the call sites.
For example, with an exported Ptr[T any](v T) *T helper, you could change the call sites as follows and remove these variables:
// at line 155
RuntimeClassName: resources.Ptr("nvidia"),
// at line 177
Privileged: resources.Ptr(true),Alternatively, you could use the standard k8s.io/utils/pointer package which provides pointer.String() and pointer.Bool() for this exact purpose.
LMCache pods need access to all GPUs on the node for CUDA IPC and custom data transfer kernels, but must not claim GPUs via nvidia.com/gpu resource requests (otherwise the serving engine loses access to them). Add runtimeClassName: nvidia, privileged: true, and NVIDIA env vars to the DaemonSet pod spec so the NVIDIA container runtime injects driver libraries and exposes all GPUs without consuming device plugin resources. Update DESIGN.md and README.md with the new requirements. Signed-off-by: royyhuang <roy.y.huang@gmail.com>
Update TestBuildDaemonSet_CustomEnvAndVolumes to expect 4 env vars instead of 3, accounting for the new NVIDIA_DRIVER_CAPABILITIES=all env var added in the previous commit. Signed-off-by: royyhuang <roy.y.huang@gmail.com>
e72afdd to
45664d0
Compare
Move path filtering from workflow-level triggers to job-level `if:` conditions using dorny/paths-filter. When jobs are skipped via `if:`, GitHub reports them as "Success" — unlike workflow-level `paths:` which causes required checks to never report, permanently blocking PRs. - test.yml: skip test matrix when no Python files changed - code_quality_checks.yml: skip pre-commit when only operator files changed Signed-off-by: royyhuang <roy.y.huang@gmail.com>
Signed-off-by: royyhuang <roy.y.huang@gmail.com> # Conflicts: # .github/workflows/code_quality_checks.yml # .github/workflows/test.yml
…e into fix/operator-gpu-driver
…lity (LMCache#2749) * [Operator] Add privileged mode and nvidia runtime for GPU visibility Signed-off-by: royyhuang <roy.y.huang@gmail.com> Co-authored-by: Yihua Cheng <yihua98@uchicago.edu>
…lity (LMCache#2749) * [Operator] Add privileged mode and nvidia runtime for GPU visibility Signed-off-by: royyhuang <roy.y.huang@gmail.com> Co-authored-by: Yihua Cheng <yihua98@uchicago.edu>
Summary
runtimeClassName: nvidiaandprivileged: trueto the DaemonSet pod spec so LMCache pods get GPU visibility via the NVIDIA container runtime without claiming GPUs throughnvidia.com/gpuresource requestsNVIDIA_DRIVER_CAPABILITIES=allenv var alongside existingNVIDIA_VISIBLE_DEVICES=allpaths:/paths-ignore:triggers to job-levelif:conditions usingdorny/paths-filter. When jobs are skipped viaif:, GitHub reports them as "Success" — unlike workflow-levelpaths:which causes required checks to never report, permanently blocking PRs that don't touch relevant files.Why
LMCache needs access to all GPUs on the node for CUDA IPC and custom data transfer kernels. However, requesting GPUs via the device plugin (
nvidia.com/gpu) would exclusively claim them, making them unavailable to the serving engine (e.g., vLLM). The combination ofruntimeClassName: nvidia+privileged: true+ NVIDIA env vars allows full GPU access without consuming device plugin resources.CI workflow changes
test.yml: Always triggers on PRs, but skips the test matrix when no Python files (**.py,pyproject.toml,requirements/**.txt) changedcode_quality_checks.yml: Always triggers on PRs, but skips pre-commit checks when onlyoperator/files changeddorny/paths-filter@v3for path detection at the job levelif:report as "Success" to GitHub, so required status checks pass without running unnecessary CITest plan
nvidia-smishows all 8 GPUs in a test pod with this configuration (nonvidia.com/gpurequest)go build ./...)