ERROR: Unable to load the kernel module 'nvidia.ko'

On a new Amazon EC2 g2.2xlarge GPU instance running Ubuntu Server 14.04 LTS, I cannot install the latest NVIDIA GRID driver. When trying to install the driver, I encounter the following error:

How can I resolve this error and proceed with installing the driver? The output below shows the OS version on the EC2 instance.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:        14.04
Codename:       trusty

Here’s the nvidia-installer.log mentioned in the error message.

Can’t read the .log the connection times out.

Have you disabled the nouveau driver?

have you checked the gcc version used by the driver package (installed on the Server) is the same one used to create the server kernel?

You may need to change the version of gcc in the VM to match.

You may also find this useful

Hey, I have the same issue when trying to install cuda
$sudo sh cuda_11.0.2_450.51.05_linux.run

Kernel module compilation complete.
→ Unable to determine if Secure Boot is enabled: No such file or directory
ERROR: Unable to load the kernel module ‘nvidia.ko’. This happens most frequently when this kernel module was built against the wrong or improperly configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if another driver, such as nouveau, is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA GPU(s), or no NVIDIA GPU installed in this system is supported by this NVIDIA Linux graphics driver release.

Please see the log entries ‘Kernel module load error’ and ‘Kernel messages’ at the end of the file ‘/var/log/nvidia-installer.log’ for more information.
→ Kernel module load error: No such device
→ Kernel messages:
[ 2.803910] Decoding supported only on Scalable MCA processors.
[ 2.812952] Decoding supported only on Scalable MCA processors.
[ 2.818914] Decoding supported only on Scalable MCA processors.
[ 2.831118] Decoding supported only on Scalable MCA processors.
[ 2.838982] Decoding supported only on Scalable MCA processors.
[ 2.846096] Decoding supported only on Scalable MCA processors.
[ 502.947087] VFIO - User Level meta-driver version: 0.3
[ 502.962436] IPMI message handler: version 39.2
[ 502.964542] ipmi device interface
[ 502.977726] nvidia: loading out-of-tree module taints kernel.
[ 502.977735] nvidia: module license ‘NVIDIA’ taints kernel.
[ 502.977736] Disabling lock debugging due to kernel taint
[ 503.052876] nvidia: module verification failed: signature and/or required key missing - tainting kernel
[ 503.133478] nvidia-nvlink: Nvlink Core is being initialized, major device number 242
[ 503.149763] ACPI: PCI Interrupt Link [LNKB] enabled at IRQ 11
[ 503.150178] NVRM: The NVIDIA GPU 0000:00:06.0 (PCI ID: 10de:2230)
NVRM: installed in this system is not supported by the
NVRM: NVIDIA 450.51.05 driver release.
NVRM: Please see ‘Appendix A - Supported NVIDIA GPU Products’
NVRM: in this release’s README, available on the operating system
NVRM: specific graphics driver download page at www.nvidia.com.
[ 503.165935] nvidia: probe of 0000:00:06.0 failed with error -1
[ 503.165952] NVRM: The NVIDIA probe routine failed for 1 device(s).
[ 503.165953] NVRM: None of the NVIDIA devices were initialized.
[ 503.166267] nvidia-nvlink: Unregistered the Nvlink Core, major device number 242

I did the following to resolve it but it didn’t work

$ vi /etc/default/grub
GRUB_TIMEOUT=1
GRUB_DISTRIBUTOR=“$(sed ‘s, release .*$,g’ /etc/system-release)”
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL=“serial console”
GRUB_SERIAL_COMMAND=“serial”
GRUB_CMDLINE_LINUX=“console=tty0 crashkernel=auto net.ifnames=0 console=ttyS0 nouveau.modeset=0”
GRUB_DISABLE_RECOVERY=“true”

$ vi /etc/modprobe.d/blacklist-nouveau.conf
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
blacklist vfio-pci

$ update-initramfs -u doesn’t work for me since I an running centos 7
So I did this instead
$ sudo dracut -v -f

$ rpm -qa kernel* |sort
kernel-3.10.0-1160.45.1.el7.x86_64
kernel-3.10.0-957.1.3.el7.x86_64
kernel-debug-devel-3.10.0-1160.45.1.el7.x86_64
kernel-devel-3.10.0-1160.45.1.el7.x86_64
kernel-headers-3.10.0-1160.45.1.el7.x86_64
kernel-tools-3.10.0-1160.45.1.el7.x86_64
kernel-tools-libs-3.10.0-1160.45.1.el7.x86_64

$reboot

I hope I can get some advice how to resolve this issue.
Thanks in advance!