Skip to content

Commit e901623

Browse files
Shiva Kumarshivakunv
authored andcommitted
gpu-manager: enable kernel module configuration via KernelModuleConfig
Signed-off-by: Shiva Kumar (SW-CLOUD) <[email protected]>
1 parent f6a13ac commit e901623

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

vgpu-manager/ubuntu22.04/nvidia-driver

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,44 @@ _set_fw_search_path() {
133133
echo -n "$nv_fw_search_path" > $fw_path_config_file
134134
}
135135

136-
# Currently _install_driver() takes care of loading nvidia modules. Just need to start necessary vgpu daemons
136+
# Load NVIDIA driver kernel modules with custom parameters and start vGPU daemons
137137
_load_driver() {
138+
local base_path="/drivers"
139+
local nvidia_params=()
140+
141+
# The installer may have already loaded the modules with default parameters
142+
# Unload them if they're already loaded
143+
if [ -f /sys/module/nvidia_vgpu_vfio/refcnt ] || [ -f /sys/module/nvidia/refcnt ]; then
144+
echo "NVIDIA modules already loaded by installer, unloading to apply custom parameters..."
145+
rmmod nvidia_vgpu_vfio 2>/dev/null || true
146+
rmmod nvidia 2>/dev/null || true
147+
fi
148+
149+
echo "Parsing kernel module parameters..."
150+
# Read parameters from nvidia.conf
151+
if [ -f "${base_path}/nvidia.conf" ]; then
152+
echo "Loading parameters from ${base_path}/nvidia.conf"
153+
while IFS="" read -r line || [ -n "$line" ]; do
154+
# Skip empty lines and comments
155+
[[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue
156+
# Remove "options nvidia " prefix if present
157+
line=$(echo "$line" | sed 's/^[[:space:]]*options[[:space:]]\+nvidia[[:space:]]\+//')
158+
if [ -n "$line" ]; then
159+
nvidia_params+=("$line")
160+
fi
161+
done <"${base_path}/nvidia.conf"
162+
if [ ${#nvidia_params[@]} -gt 0 ]; then
163+
echo "Module parameters for nvidia: ${nvidia_params[@]}"
164+
fi
165+
fi
166+
167+
echo "Loading NVIDIA driver kernel modules..."
168+
set -o xtrace +o nounset
169+
modprobe nvidia ${nvidia_params[@]+"${nvidia_params[@]}"}
170+
modprobe nvidia_vgpu_vfio
171+
set +o xtrace -o nounset
172+
173+
# Start vGPU daemons
138174
/usr/bin/nvidia-vgpud
139175
/usr/bin/nvidia-vgpu-mgr &
140176

0 commit comments

Comments
 (0)