Handle gdrdrv kernel module in _unload_driver()#869
Open
shaq918 wants to merge 1 commit into
Open
Conversation
The _unload_driver() function accounts for nvidia_modeset, nvidia_uvm, and nvidia_peermem when computing nvidia_deps, but does not account for gdrdrv (loaded by the nvidia-gdrcopy-ctr sidecar container). When RDMA is enabled in the GPU Operator ClusterPolicy, the driver pod runs three containers: nvidia-driver-ctr, nvidia-peermem-ctr, and nvidia-gdrcopy-ctr. The gdrcopy container loads the gdrdrv kernel module, which holds a reference on the nvidia module. If the driver container restarts (e.g. due to upgrade, pod eviction, or node reboot), it calls _unload_driver() while gdrdrv is still loaded. The nvidia module refcount (4) exceeds the expected nvidia_deps count (3), causing the unload to fail with "Could not unload NVIDIA driver kernel modules, driver is in use". The driver container then enters CrashLoopBackOff. This adds gdrdrv to the set of known nvidia-dependent modules, matching the existing pattern used for nvidia_modeset, nvidia_uvm, and nvidia_peermem. When gdrdrv is present, it is added to rmmod_args and nvidia_deps is incremented so the refcount check passes correctly. Signed-off-by: Shashank Mohankumar <smohankumar@crusoe.ai>
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.
Summary
The
_unload_driver()function in the driver container entrypoint script accounts fornvidia_modeset,nvidia_uvm, andnvidia_peermemwhen computingnvidia_deps, but does not account forgdrdrv(loaded by thenvidia-gdrcopy-ctrsidecar container). This causes the driver container to enterCrashLoopBackOffwhen it restarts on nodes where GDRCopy is enabled.Problem
When RDMA is enabled in the GPU Operator
ClusterPolicy(driver.rdma.enabled: true), the driver pod runs three containers:nvidia-driver-ctrnvidia,nvidia_modeset,nvidia_uvmnvidia-peermem-ctrnvidia_peermemnvidia-gdrcopy-ctrgdrdrvAll four dependent modules (
nvidia_modeset,nvidia_uvm,nvidia_peermem,gdrdrv) hold references on thenvidiamodule. However,_unload_driver()only counts three of them innvidia_deps. When the driver container restarts (e.g. due to upgrade, pod eviction, or node reboot), it calls_unload_driver()whilegdrdrvis still loaded by the co-located gdrcopy sidecar. Thenvidiamodule refcount (4) exceeds the expectednvidia_depscount (3), and the function bails out with:The driver container then enters
CrashLoopBackOff. The only recovery is to delete the entire driver pod (which terminates the gdrcopy sidecar and unloadsgdrdrv), but the issue recurs on any subsequent driver container restart.Observed in production across multiple clusters running H100/H200 GPU nodes with InfiniBand and GDRCopy enabled.
Fix
Add
gdrdrvto the set of known nvidia-dependent modules in_unload_driver(), matching the existing pattern used fornvidia_modeset,nvidia_uvm, andnvidia_peermem:When
gdrdrvis present, it is added tormmod_args(so it gets unloaded) andnvidia_depsis incremented (so the refcount check passes). Whengdrdrvis not present (no GDRCopy), the block is a no-op.Applied to all 11
nvidia-driverscripts across ubuntu22.04, ubuntu24.04, ubuntu26.04, rhel8, rhel9, and rhel10 (both compiled and precompiled variants).Reproduction
driver.rdma.enabled: true(enables peermem + gdrcopy sidecars)gdrdrvis loaded:lsmod | grep gdrdrv→nvidia refcnt=4Init:CrashLoopBackOffwith "Could not unload NVIDIA driver kernel modules"Testing
gdrdrvalong with the other modules, nvidia refcount check passes, clean reinstallgdrdrvsysfs entry doesn't exist, the new block is skipped entirely — no behavior change