Compile Nvidia Driver Kernel Module (nvidia.ko) without Loading It


I’m compiling the Nvidia Driver for my graphic card for a Docker container running Ubuntu and I’m running into a dilemma:

  • The first issue is about Nouveau driver. It is extremely difficult to disable Nouveau in Dockerfile since all the methods regarding to removing of Nouveau require “rebooting” the system.

  • As a result, when installing the driver, I’m using the following flags

    RUN ./ --silent --no-nouveau-check

  • Note that I’m compiling the driver with a different kernel header.
    I also specified --no-nouveau-check since I can’t disable Nouveau as mentioned above.

  • However, when the driver is compiled and nvidia.ko created, the installation process will try to load the nvidia.ko. It definitely fails since Nouveau is still there.

My question is: Is there a way to only compile the driver kernel module nvidia.ko, without attempting to load it at the end of installation?