Fully Working Patch for Nvidia Driver 340.102 [Compiler/Installer File] and Linux Kernel 4.11

For those who would like to immediately begin using Nvidia Driver 340.102 with Linux Kernel 4.11-rcX / 4.11, apply the fully working patch provided here:

  • Name of the patch file is: “nv_patch_340.102_linux_kernel_4.11”, see direct links or extract from attached “patch.zip” file below

  • The patch is a cleaned-up combination of 3 individual patches for Linux Kernels 4.9, 4.10, & 4.11

  • I have fully tested the patch and it works well without any issues

  • 100% FULL CREDIT and MANY THANKS for those original, individual patches go out to: Alberto Milone, Michael Marley, & Robert Hooker

Instructions for Applying Patch [nv_patch_340.102_linux_kernel_4.11] to Nvidia Driver Compiler/Installer 340.102 used with Linux Kernel 4.11 in CLI/Terminal:

  1. Download the following NVIDIA Driver Compiler/Installer file from NVIDIA website for Linux: NVIDIA-Linux-x86_64-340.102.run
  2. Go into CLI/Terminal, and SU into root(#)
  3. Completely Exit Xorg Server: The command “systemctl isolate multi-user.target” usually followed by “CTL+ALT+[F1 to F6]” will do this
  4. In CLI, go into root then provide execution permissions: “chmod 755 NVIDIA-Linux-x86_64-340.102.run”
  5. Extract the Nvidia Driver Compiler/Installer Contents & Source Files: “./NVIDIA-Linux-x86_64-340.102.run --extract-only”
  6. Copy [cp] Patch File “nv_patch_340.102_linux_kernel_4.11” into “NVIDIA-Linux-x86_64-340.102” directory
  7. Go into [cd] “NVIDIA-Linux-x86_64-340.102” directory where patch file is now located
  8. Apply Patch in that directory: “patch -p0 < nv_patch_340.102_linux_kernel_4.11”
  9. Proceed with NVIDIA Driver Compilation & Installation by running “./nvidia-installer”. Important: Make sure the Nouveau Driver is disabled-blacklisted and modeset set to 0 in /etc/modprobe.d with “blacklist nouveau” & “options nouveau modeset=0”, and the Initial RAM Disk (initrd) is created prior to compiling, installing & rebooting. Enjoy!

Note: You may wish to test out the patch first by executing a Dry-Run with:
“patch --dry-run -p0 < nv_patch_340.102_linux_kernel_4.11”

Pastebin & Google links for patch “nv_patch_340.102_linux_kernel_4.11”:
https://pastebin.com/raw/stBSENAk & https://goo.gl/VQpoY2

patch.zip (2.15 KB)

I tried this and it fails with “ERROR: Unable to load kernel module”
When I tried modprobe myself it said it couldn’t find nvidea_375 I’m guessing that’s the problem since I believe it’s supposed to look for nvidea_340 but I have no idea how to fix this

Reply to Dav1d1700, who said:

The post I made clearly indicates the patch is for Nvidia Linux Driver 340.102, and NOT 375, and is only to be used with Linux Kernel 4.11.

Thanks! Works great!

Ben

Can confirm patch worked on my system as well.

Thanks ejmarkow much appreciated.

Tip: to avoid typing error hassels change patch and NVIDIA driver run file names to simpler names prior to leaving Xorg graphics mode for installation

I can confirm these instructions work for Fedora 25 with kernel 4.11.x. Thanks for posting.

Hi everyone!!

my problem:

uname -a

Linux hydra-deb 4.11.0-1-amd64 #1 SMP Debian 4.11.6-1 (2017-06-19) x86_64 GNU/Linux

cat /etc/debian_version

buster/sid

patch 4.11
2# patch -p0 < nv_patch_340.102_linux_kernel_4.11

patching file kernel/nv-linux.h
patching file kernel/nv-pat.c
patching file kernel/uvm/nvidia_uvm_lite.c
patching file kernel/nv-drm.c
patching file kernel/uvm/nvidia_uvm_linux.h
patching file kernel/uvm/nvidia_uvm_lite.c
Hunk #1 succeeded at 818 with fuzz 2.
patching file kernel/nv-drm.c

install and log

ERROR: Failed to run `/usr/sbin/dkms build -m nvidia -v 340.102 -k 4.11.0-1-amd64`:
         Kernel preparation unnecessary for this kernel.  Skipping...

         Building module:
         cleaning build area...
         make -j2 KERNELRELEASE=4.11.0-1-amd64 module KERNEL_UNAME=4.11.0-1-amd64; make -C uvm module KERNEL_UNAME=4.11.0-1-amd64
         KBUILD_EXTMOD=/var/lib/dkms/nvidia/340.102/build/uvm; make -C uvm module KERNEL_UNAME=4.11.0-1-amd64 KBUILD_EXTMOD=/var/lib/dkms/nvidia/340.102/build/uvm; make -C uvm
         module KERNEL_UNAME=4.11.0-1-amd64 KBUILD_EXTMOD=/var/lib/dkms/nvidia/340.102/build/uvm...(bad exit status: 2)
         Error! Bad return status for module build on kernel: 4.11.0-1-amd64 (x86_64)
         Consult /var/lib/dkms/nvidia/340.102/build/make.log for more information.

dkms log (very long and with PL signs)
/var/lib/dkms/nvidia/340.102/build/make.log

DKMS make.log for nvidia-340.102 for kernel 4.11.0-1-amd64 (x86_64)
pon, 10 lip 2017, 11:23:52 CEST

gcc-version-check failed:

The compiler used to compile the kernel (gcc
6.3) does not exactly match the current compiler
(gcc 6.4).  The Linux 2.6 kernel module loader
rejects kernel modules built with a version of gcc
that does not exactly match that of the compiler
used to build the running kernel.

If you know what you are doing and want to override
the gcc version check, you can do so by setting the
IGNORE_CC_MISMATCH environment variable to "1".

In any other case, set the CC environment variable
to the name of the compiler that was used to compile
the kernel.

*** Failed CC version check. Bailing out! ***

nvidia-modules-common.mk:201: polecenia dla obiektu 'build-sanity-checks' nie powiodły się
make: *** [build-sanity-checks] Błąd 1
make: Wejście do katalogu '/var/lib/dkms/nvidia/340.102/build/uvm'
cd ./..; make module SYSSRC=/lib/modules/4.11.0-1-amd64/source SYSOUT=/lib/modules/4.11.0-1-amd64/build KBUILD_EXTMOD=./..
make[1]: Wejście do katalogu '/var/lib/dkms/nvidia/340.102/build'
NVIDIA: calling KBUILD...
make[2]: Wejście do katalogu '/usr/src/linux-headers-4.11.0-1-common'
make -C /lib/modules/4.11.0-1-amd64/build KBUILD_SRC=/usr/src/linux-headers-4.11.0-1-common \
-f /usr/src/linux-headers-4.11.0-1-common/Makefile modules
make[3]: Wejście do katalogu '/usr/src/linux-headers-4.11.0-1-amd64'
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (                \
echo >&2;                                                       \
echo >&2 "  ERROR: Kernel configuration is invalid.";           \
echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";      \
echo >&2 ;                                                      \
/bin/false)
mkdir -p ./../.tmp_versions ; rm -f ./../.tmp_versions/*
make -f /usr/src/linux-headers-4.11.0-1-common/scripts/Makefile.build obj=./..
/usr/src/linux-headers-4.11.0-1-common/scripts/Makefile.build:44: /usr/src/linux-headers-4.11.0-1-common/./../Makefile: Nie ma takiego pliku ani katalogu
make[4]: *** Brak reguł do wykonania obiektu '/usr/src/linux-headers-4.11.0-1-common/./../Makefile'. Stop.
/usr/src/linux-headers-4.11.0-1-common/Makefile:1509: polecenia dla obiektu '_module_./..' nie powiodły się
make[3]: *** [_module_./..] Błąd 2
make[3]: Opuszczenie katalogu '/usr/src/linux-headers-4.11.0-1-amd64'
Makefile:152: polecenia dla obiektu 'sub-make' nie powiodły się
make[2]: *** [sub-make] Błąd 2
make[2]: Opuszczenie katalogu '/usr/src/linux-headers-4.11.0-1-common'
NVIDIA: left KBUILD.
nvidia.ko failed to build!
Makefile:185: polecenia dla obiektu 'nvidia.ko' nie powiodły się
make[1]: *** [nvidia.ko] Błąd 1
make[1]: Opuszczenie katalogu '/var/lib/dkms/nvidia/340.102/build'
Makefile:219: polecenia dla obiektu '../Module.symvers' nie powiodły się
make: *** [../Module.symvers] Błąd 2
make: Opuszczenie katalogu '/var/lib/dkms/nvidia/340.102/build/uvm'
make: Wejście do katalogu '/var/lib/dkms/nvidia/340.102/build/uvm'
cd ./..; make module SYSSRC=/lib/modules/4.11.0-1-amd64/source SYSOUT=/lib/modules/4.11.0-1-amd64/build KBUILD_EXTMOD=./..
make[1]: Wejście do katalogu '/var/lib/dkms/nvidia/340.102/build'
NVIDIA: calling KBUILD...
make[2]: Wejście do katalogu '/usr/src/linux-headers-4.11.0-1-common'
make -C /lib/modules/4.11.0-1-amd64/build KBUILD_SRC=/usr/src/linux-headers-4.11.0-1-common \
-f /usr/src/linux-headers-4.11.0-1-common/Makefile modules
make[3]: Wejście do katalogu '/usr/src/linux-headers-4.11.0-1-amd64'
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (                \
echo >&2;                                                       \
echo >&2 "  ERROR: Kernel configuration is invalid.";           \
echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";      \
echo >&2 ;                                                      \
/bin/false)
mkdir -p ./../.tmp_versions ; rm -f ./../.tmp_versions/*
make -f /usr/src/linux-headers-4.11.0-1-common/scripts/Makefile.build obj=./..
/usr/src/linux-headers-4.11.0-1-common/scripts/Makefile.build:44: /usr/src/linux-headers-4.11.0-1-common/./../Makefile: Nie ma takiego pliku ani katalogu
make[4]: *** Brak reguł do wykonania obiektu '/usr/src/linux-headers-4.11.0-1-common/./../Makefile'. Stop.
/usr/src/linux-headers-4.11.0-1-common/Makefile:1509: polecenia dla obiektu '_module_./..' nie powiodły się
make[3]: *** [_module_./..] Błąd 2
make[3]: Opuszczenie katalogu '/usr/src/linux-headers-4.11.0-1-amd64'
Makefile:152: polecenia dla obiektu 'sub-make' nie powiodły się
make[2]: *** [sub-make] Błąd 2
make[2]: Opuszczenie katalogu '/usr/src/linux-headers-4.11.0-1-common'
NVIDIA: left KBUILD.
nvidia.ko failed to build!
Makefile:185: polecenia dla obiektu 'nvidia.ko' nie powiodły się
make[1]: *** [nvidia.ko] Błąd 1
make[1]: Opuszczenie katalogu '/var/lib/dkms/nvidia/340.102/build'
Makefile:219: polecenia dla obiektu '../Module.symvers' nie powiodły się
make: *** [../Module.symvers] Błąd 2
make: Opuszczenie katalogu '/var/lib/dkms/nvidia/340.102/build/uvm'
make: Wejście do katalogu '/var/lib/dkms/nvidia/340.102/build/uvm'
cd ./..; make module SYSSRC=/lib/modules/4.11.0-1-amd64/source SYSOUT=/lib/modules/4.11.0-1-amd64/build KBUILD_EXTMOD=./..
make[1]: Wejście do katalogu '/var/lib/dkms/nvidia/340.102/build'
NVIDIA: calling KBUILD...
make[2]: Wejście do katalogu '/usr/src/linux-headers-4.11.0-1-common'
make -C /lib/modules/4.11.0-1-amd64/build KBUILD_SRC=/usr/src/linux-headers-4.11.0-1-common \
-f /usr/src/linux-headers-4.11.0-1-common/Makefile modules
make[3]: Wejście do katalogu '/usr/src/linux-headers-4.11.0-1-amd64'
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (                \
echo >&2;                                                       \
echo >&2 "  ERROR: Kernel configuration is invalid.";           \
echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";      \
echo >&2 ;                                                      \
/bin/false)
mkdir -p ./../.tmp_versions ; rm -f ./../.tmp_versions/*
make -f /usr/src/linux-headers-4.11.0-1-common/scripts/Makefile.build obj=./..
/usr/src/linux-headers-4.11.0-1-common/scripts/Makefile.build:44: /usr/src/linux-headers-4.11.0-1-common/./../Makefile: Nie ma takiego pliku ani katalogu
make[4]: *** Brak reguł do wykonania obiektu '/usr/src/linux-headers-4.11.0-1-common/./../Makefile'. Stop.
/usr/src/linux-headers-4.11.0-1-common/Makefile:1509: polecenia dla obiektu '_module_./..' nie powiodły się
make[3]: *** [_module_./..] Błąd 2
make[3]: Opuszczenie katalogu '/usr/src/linux-headers-4.11.0-1-amd64'
Makefile:152: polecenia dla obiektu 'sub-make' nie powiodły się
make[2]: *** [sub-make] Błąd 2
make[2]: Opuszczenie katalogu '/usr/src/linux-headers-4.11.0-1-common'
NVIDIA: left KBUILD.
nvidia.ko failed to build!
Makefile:185: polecenia dla obiektu 'nvidia.ko' nie powiodły się
make[1]: *** [nvidia.ko] Błąd 1
make[1]: Opuszczenie katalogu '/var/lib/dkms/nvidia/340.102/build'
Makefile:219: polecenia dla obiektu '../Module.symvers' nie powiodły się
make: *** [../Module.symvers] Błąd 2
make: Opuszczenie katalogu '/var/lib/dkms/nvidia/340.102/build/uvm'

var/log/nvidia-innstaller.log

nvidia-installer log file '/var/log/nvidia-installer.log'
creation time: Mon Jul 10 10:58:55 2017
installer version: 340.102

PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

nvidia-installer command line:
    ./nvidia-installer

Unable to load: nvidia-installer ncurses v6 user interface

Using: nvidia-installer ncurses user interface
-> License accepted.
-> Installing NVIDIA driver version 340.102.
-> There appears to already be a driver installed on your system (version: 340.102).  As part of installing this driver (version: 340.102), the existing driver will be uninstalled$
-> Would you like to register the kernel module sources with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later. (Answer: No)
-> Performing CC sanity check with CC="/usr/bin/cc".
-> The CC version check failed:

what can i do now?

Colej,

After you apply your patch, try running the Nvidia Installer / Compilation file using the following:

./nvidia-installer --no-cc-version-check

Let us know your result.

it works, thanks

Now how about a 340.102 patch for Linux 4.12.* ??? Or better yet, driver 340.103 ???

You mean like there is here…?

https://devtalk.nvidia.com/default/topic/1008771/linux/nvidia-340-xx-compile-error-with-kernel-4-12-rc1/post/5179612/#5179612