在Ubuntu16.04上安装cuda时,报如下错误;

Installing the NVIDIA display driver…
The driver installation is unable to locate the kernel source. Please make sure that the kernel source packages are installed and set up correctly.
If you know that the kernel source packages are installed and set up correctly, you may pass the location of the kernel source with the ‘–kernel-source-path’ flag.

主要是由于内核版本版本过高(由下图可知,ubuntu 16.04目前内核版本需要是4.4,如果是4.4以上应该就需要降版本),可以通过降低内核版本的方式解决,

cuda  The driver installation is unable to locate the kernel source_linux
首先,通过uname -r查看内核版本,例如输出为4.13.0-26-generic
则执行,

sudo apt-get purge linux-image-4.13.0-26-generic
sudo apt-get purge linux-headers-4.13.0-26-generic

sudo update-initramfs -u

重启后,重新安装cuda,即可正常安装。