I solved the 340.120 issue with kernel 4.13.0-26-generic Ubuntu 16.04.3 LTS ....
Boot with an older kernel, download this patch: https://devtalk.nvidia.com/default/topic/1019362/fully-working-patch- for-nvidia-driver-340-102-compiler-installer-file-and-linux-kernel-4-12/ Rename and copy the patch in /usr/src/nvidia-340-340.102/patches/buildfix_kernel-4.12.patch Modified the dkms.conf by disable patch 4.9 & 4.10 and enable only patch 4.12. Part of the dkms.conf: .... #PATCH[0]="buildfix_kernel_4.9.patch" #PATCH[1]="buildfix_kernel_4.10.patch" PATCH[0]="buildfix_kernel_4.12.patch" #PATCH_MATCH[0]="^3.[8-9]" .... Build and Install the kernel module: sudo dkms build -m nvidia-340 -v 340.102 -k 4.13.0-26-generic sudo dkms install -m nvidia-340 -v 340.102 -k 4.13.0-26-generic Reboot -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1741671 Title: nvidia-340 340.102-0ubuntu0.16.04.2: nvidia-340 kernel module failed to build [nv-linux.h:199:2: error: #error "This driver requires the ability to change memory types!"] To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/linux-hwe/+bug/1741671/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs