Handle gdrdrv kernel module in _unload_driver()#869
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>
|
The |
|
Thanks for taking a look @tariq1890. The failing scenario is a container-level restart of Sequence (
I reproduced this cleanly today (gpu-operator v25.10.1, Trigger: stopped only the driver container ( The excess reference is gdrdrv alone (refcnt 3 vs the expected 2). After The change follows the existing precedent in the same function: One related observation from the repro: after recovery, |
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