@@ -8,6 +8,7 @@ DRIVER_RESET_RETRIES=10
88DELAY_BEFORE_VF_CREATION=${DELAY_BEFORE_VF_CREATION:- 15}
99KERNEL_VERSION=$( uname -r)
1010RUN_DIR=/run/nvidia
11+ NVIDIA_MODULE_PARAMS=()
1112
1213export DEBIAN_FRONTEND=noninteractive
1314
@@ -133,8 +134,47 @@ _set_fw_search_path() {
133134 echo -n " $nv_fw_search_path " > $fw_path_config_file
134135}
135136
136- # Currently _install_driver() takes care of loading nvidia modules. Just need to start necessary vgpu daemons
137+ # For each kernel module configuration file mounted into the container,
138+ # parse the file contents and extract the custom module parameters that
139+ # are to be passed as input to 'modprobe'.
140+ #
141+ # Assumptions:
142+ # - Configuration file is named nvidia.conf
143+ # - Configuration file is mounted inside the container at /drivers.
144+ # - Each line in the file contains at least one parameter, where parameters on the same line
145+ # are space delimited. It is up to the user to properly format the file to ensure
146+ # the correct set of parameters are passed to 'modprobe'.
147+ _get_module_params () {
148+ local base_path=" /drivers"
149+ # nvidia
150+ if [ -f " ${base_path} /nvidia.conf" ]; then
151+ while IFS=" " read -r param || [ -n " $param " ]; do
152+ NVIDIA_MODULE_PARAMS+=(" $param " )
153+ done < " ${base_path} /nvidia.conf"
154+ echo " Module parameters provided for nvidia: ${NVIDIA_MODULE_PARAMS[@]} "
155+ fi
156+ }
157+
158+ # Load NVIDIA driver kernel modules with custom parameters and start vGPU daemons
137159_load_driver () {
160+ # The installer may have already loaded the modules with default parameters
161+ # Unload them if they're already loaded so we can reload with custom parameters
162+ if [ -f /sys/module/nvidia_vgpu_vfio/refcnt ] || [ -f /sys/module/nvidia/refcnt ]; then
163+ echo " NVIDIA modules already loaded by installer, unloading to apply custom parameters..."
164+ rmmod nvidia_vgpu_vfio 2> /dev/null || true
165+ rmmod nvidia 2> /dev/null || true
166+ fi
167+
168+ echo " Parsing kernel module parameters..."
169+ _get_module_params
170+
171+ echo " Loading NVIDIA driver kernel modules..."
172+ set -o xtrace +o nounset
173+ modprobe nvidia " ${NVIDIA_MODULE_PARAMS[@]} "
174+ modprobe nvidia_vgpu_vfio
175+ set +o xtrace -o nounset
176+
177+ # Start vGPU daemons
138178 /usr/bin/nvidia-vgpud
139179 /usr/bin/nvidia-vgpu-mgr &
140180
0 commit comments