参考文章《Installing Nvidia CUDA 8.0 on Ubuntu 16.04 for Linux GPU Computing (New Troubleshooting Guide)》
sudo service lightdm stop
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get install build-essential
echo -e "blacklist nouveau\nblacklist lbm-nouveau\noptions nouveau modeset=0\nalias nouveau off\nalias lbm-nouveau off\n" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
sudo update-initramfs -u
apt-get install linux-image-extra-virtual
apt-get install linux-source
apt-get source linux-image-$(uname -r)
apt-get install linux-headers-$(uname -r)
wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run
sudo sh cuda_8.0.61_375.26_linux.run --override --no-opengl-lib
Do you accept the previously read EULA? (accept/decline/quit): accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26? ((y)es/(n)o/(q)uit): y
Install the CUDA 8.0 Toolkit? ((y)es/(n)o/(q)uit): y
Enter Toolkit Location [ default is /usr/local/cuda-8.0 ]:
Do you want to install a symbolic link at /usr/local/cuda? ((y)es/(n)o/(q)uit): y
Install the CUDA 8.0 Samples? ((y)es/(n)o/(q)uit): y
Enter CUDA Samples Location [ default is /home/user ]: /usr/local/cuda-8.0
sudo apt install mokutil
sudo mokutil --disable-validation
为了安装cuda9.0,先把前面安装的Nvidia驱动卸载了,sudo apt-get remove nvidia-(版本号)。
然后,按照上面的文章从头到尾做了一次,最后还是失败了。看了log文件,是最后的编译没通过,估计是内核源码头文件版本不对。下载的驱动linux版本只有17.04或者16.04的,而我这里安装的是17.10和16.10,以后有时间再试吧。