Fix NVIDIA driver 387 for Linux kernel 4.13+ on Ubuntu

Apparently, the current NVIDIA drivers (387) which comes with CUDA 9.1 doesn’t compile with the new Linux kernels (4.13+) on Ubuntu. The error report from DKMS will say something like:

 /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_va_block.c: In function ‘block_cpu_fault_locked’:
 ./arch/x86/include/asm/processor.h:820:39: error: implicit declaration of function ‘task_stack_page’ [-Werror=implicit-function-declaration]
   unsigned long __ptr = (unsigned long)task_stack_page(task);

Here is a quick fix to resolve the issue:

I hereby assume you are trying to install the NVIDIA 387.26 driver. If you are trying to install another version of the driver, be sure to change the version numbers in the recipe below.

Edit the file /var/lib/dkms/nvidia-387/387.26/source/nvidia-uvm/uvm8_va_block.c and add the following to the top of the file:

#include <linux/sched/task_stack.h>

Next, you need to build and install the DKMS module:

sudo dkms build nvidia-387/387.26
sudo dkms install nvidia-387/387.26

Finally, reboot!

You may also like...

2 Responses

  1. Anonymous says:

    Thank you! Worked for me!

  2. Anonymous says:

    Works!
    Thanks a lot.

Leave a Reply

Your email address will not be published.