Resolution: PATCH (Attached) for NVIDIA Linux Driver 340.98 (x86_64) using Linux Kernel 4.9

Great news!

I have thoroughly tested the attached driver PATCH which RESOLVES the issue of NVIDIA Linux Driver 340.98 (x86_64) not working with Linux Kernel 4.9 (Forum Reference: https://devtalk.nvidia.com/default/topic/973807/linux/nvidia-linux-x86_64-340-98-driver-not-building-with-kernel-4-9-0-rc2-/).

The patch works like a charm!

First, credit and many “thanks” goes out to those who originally created the patch (I only fine-tuned it for use here):

Link to original PATCH info: https://launchpad.net/ubuntu/+source/nvidia-graphics-drivers-340/340.98-0ubuntu2

  • To Michael Marley for adding support for Linux Kernel 4.9 & for finding out about the new required DRIVER_LEGACY flag

  • To Alberto Milone for uploading it to launchpad.net

  • To Ubuntu / Canonical Group

PATCH on Pastebin: http://pastebin.com/raw/0XE0e8Wx

For those who need it, my brief set of Instructions for Applying the Patch to Nvidia Driver 340.98 using Linux Kernel 4.9 in CLI/Terminal:

  1. Download the following NVIDIA binary/driver file from NVIDIA website for Linux: NVIDIA-Linux-x86_64-340.98.run
  2. Go into CLI/Terminal
  3. Provide execution permissions: chmod 755 NVIDIA-Linux-x86_64-340.98.run
  4. Extract: ./chmod 755 NVIDIA-Linux-x86_64-340.98.run --extract-only
  5. Copy Patch File “nv_patch_340.98_final” into “NVIDIA-Linux-x86_64-340.98” directory
  6. Go into (cd into) “NVIDIA-Linux-x86_64-340.98” directory where patch file is now located
  7. Apply Patch: patch -p0 < nv_patch_340.98_final
  8. Proceed with NVIDIA Driver Installation, Enjoy!

NOTE: NVIDIA DEVS may want to pin this post and incorporate the fully functioning patch into the driver.
nv_patch_340.98_final.zip (856 Bytes)

340.101 builds fine without patching.

leigh123linux

What a coincidence, that driver was just released today!


Version: 340.101
Release Date: 2016.12.14
Operating System: Linux 64-bit
Language: English (US)
File Size: 66.8 MB

Great, so the patch is no longer necessary.

Tested NVIDIA Linux Driver 340.101 thoroughly with Kernel 4.9 today.

Result: Both the drivers nvidia.ko & nvidia-uvm.ko Compile/Build Properly, however, they Fail to Load.

Attached is the corresponding nvidia-installer.log which clearly indicates the results.

A pertinent excerpt of the log:


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 a driver such as rivafb, nvidiafb, or nouveau is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA graphics device(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:
[ 1092.921957]  [<ffffffffa08da900>] nv_register_procfs+0x3d/0x1a0 [nvidia]
[ 1092.922174]  [<ffffffffa1789245>] nvidia_init_module+0x245/0x701 [nvidia]
[ 1092.922386]  [<ffffffffa1789716>] ? nv_drm_init+0x15/0x15 [nvidia]
[ 1092.922574]  [<ffffffffa1789766>] nvidia_frontend_init_module+0x50/0x8ea [nvidia]
[ 1092.922739]  [<ffffffffa1789716>] ? nv_drm_init+0x15/0x15 [nvidia]
[ 1092.922744]  [<ffffffff8100043e>] do_one_initcall+0x90/0x113
[ 1092.922747]  [<ffffffff815c3fe9>] ? _cond_resched+0x19/0x23
[ 1092.922750]  [<ffffffff811698ce>] ? slab_pre_alloc_hook+0x19/0x1f
[ 1092.922753]  [<ffffffff8116c717>] ? kmem_cache_alloc_trace+0xbe/0xcd
[ 1092.922757]  [<ffffffff81122c37>] do_init_module+0x5f/0x1ef
[ 1092.922761]  [<ffffffff810bd293>] load_module+0x1a9c/0x2003
[ 1092.922764]  [<ffffffff8117ea31>] ? fsnotify_access+0x5a/0x61
[ 1092.922766]  [<ffffffff810b9bb4>] ? strstarts+0x28/0x28
[ 1092.922769]  [<ffffffff810bd987>] SYSC_finit_module+0x83/0x90
[ 1092.922771]  [<ffffffff810bd987>] ? SYSC_finit_module+0x83/0x90
[ 1092.922773]  [<ffffffff810bd9b2>] SyS_finit_module+0xe/0x10
[ 1092.922776]  [<ffffffff815c68e4>] entry_SYSCALL_64_fastpath+0x17/0x98
[ 1092.922779] ---[ end trace a38d66f1d193dd50 ]---
[ 1092.922782] NVRM: failed to register procfs!
[ 1092.922851] NVRM: request_mem_region failed for 16M @ 0xe0000000. This can
               NVRM: occur when a driver such as rivatv is loaded and claims
               NVRM: ownership of the device's registers.
[ 1092.922859] nvidia: probe of 0000:01:00.0 failed with error -1
[ 1092.922900] Error: Driver 'nvidia' is already registered, aborting...
[ 1092.922901] NVRM: DRM init failed

What does work perfectly is NVIDIA Linux Driver 340.98 with PATCH mentioned in this post.

nvidia-installer.log (865 KB)