Nvidia Legacy driver (340.106) will not compile under RH 7.5 kernel

I’m upgrading some old linux machines from 7.4 to 7.5 with legacy graphics card. 340.106 works fine under the 3.10.0-693.21.1 kernel , but when I upgrade to 3.10.0-862 (or 861) it fails to install. The error messages seem to be related to get_user_pages function. However that function prototype doesn’t seem to have changed between those two versions.


In file included from /tmp/selfgz23204/NVIDIA-Linux-x86_64-340.106/kernel/nv.c:13:0:
   /tmp/selfgz23204/NVIDIA-Linux-x86_64-340.106/kernel/nv-linux.h:2126:13: error: too few arguments to function ‘get_user_pages’
                return get_user_pages(start, nr_pages, flags, pages, vmas);
   In file included from /tmp/selfgz23204/NVIDIA-Linux-x86_64-340.106/kernel/nv-linux.h:68:0,
                    from /tmp/selfgz23204/NVIDIA-Linux-x86_64-340.106/kernel/nv.c:13:
   /usr/src/kernels/3.10.0-861.el7.x86_64/include/linux/mm.h:1381:6: note: declared here
    long get_user_pages(struct task_struct *tsk, struct mm_struct *mm,

  In file included from /tmp/selfgz23204/NVIDIA-Linux-x86_64-340.106/kernel/nv.c:13:0:
   /tmp/selfgz23204/NVIDIA-Linux-x86_64-340.106/kernel/nv-linux.h:2153:45: error: too few arguments to function ‘get_user_pages_remote’
                                                pages, vmas);
   In file included from /tmp/selfgz23204/NVIDIA-Linux-x86_64-340.106/kernel/nv-linux.h:68:0,
                    from /tmp/selfgz23204/NVIDIA-Linux-x86_64-340.106/kernel/nv.c:13:

nvidia-compile.txt (16.2 KB)

RH did a lot of backporting. Attached are two patches. One changes the get_user_pages wrapper to the current version, and the other one injects the proper defines for 7.5 (unconditionally). Works for me.

As an aside: RH did so much backporting, you now even see something like this:

nvidia 0000:01:00.0: irq 31 for MSI/MSI-X
resource sanity check: requesting [mem 0x000c0000-0x000fffff], which spans more than PCI Bus 0000:00 [mem 0x000d0000-0x000dffff window]
caller os_map_kernel_space+0xad/0xe0 [nvidia] mapping multiple BARs

–> https://devtalk.nvidia.com/default/topic/1026975/nvidia-related-warning-on-booting-linux-4-14/

Verdammte Schlamperei!

fix_config.txt (929 Bytes)
fix_wrapper.txt (4.69 KB)


I tried your patching suggestion and it now builds successfully!
Thank you very much for posting this answer!

Hi, how exactly do you apply those patches?
I’m stuck trying to install CUDA 8.0 on Ubuntu 18.04.

This thread is obsolete. Install 340.107 instead. And 340 is only good for cuda up to 6.5.

For Ubuntu, the patches are included in the repo drivers

  • Don’t use the .run installers, use --uninstall to uninstall them
  • purge anthing nvidia/cuda
  • install the driver from repo (sudo apt install nvidia-driver-340)
  • download the cuda .deb
  • add the repo to your system (first three steps from install instructions on download page)
  • don’t install cuda
  • instead, run sudo apt install cuda-toolkit-8-0