Download


  • I have installed both the graphics driver and cuda from a single installation file cuda_9.0.176_384.81_linux.run. It comes with compatible driver version 384. So you have not to worry about driver compatibility issue. Following link will show downloadable run file (1.6 GB) for ubuntu 16.04. https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=runfilelocal

Installation


1) Pre-installation
  • Verify the system has a CUDA-capable GPU.
  • Verify the system is running a supported version of Linux.
  • Verify the system has gcc installed.
  • If there is any NVIDIA driver already installed, uninstall it for safety (not mandatory)
$ sudo apt-get purge nvidia* 
2) Disabling Nouveau
  • To install the Display Driver, the Nouveau drivers must first be disabled. The Nouveau drivers are loaded if the following command prints anything:
$ lsmod | grep nouveau
  • If nouveau is enabled then:

i) Create a file at /etc/modprobe.d/blacklist-nouveau.conf with the following contents:

blacklist nouveau
options nouveau modeset=0

ii) Regenerate the kernel initramfs:

$ sudo update-initramfs -u
3) Stop X server service
  • Hit Ctrl+Alt+F1 and login using your credentials.
  • Kill your current X server session by typing
$ sudo service lightdm stop

or

$ sudo lightdm stop
  • Enter runlevel 3 by typing
$ sudo init 3
  • Install your *.run file.
  • Make exucutable
$ chmod +x ./your-nvidia-file.run
  • Execute the file with
$ sudo ./your-nvidia-file.run
4) Reboot
  • You might be required to reboot when the installation finishes.
$ reboot
5) Add bin to PATH and libs to LD_LIBRARY_PATH
  • Add following lines to .bashrc
export PATH="/usr/local/cuda/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"
  • Reload .bashrc with
$ source .bashrc

6) Verify installation

  • Following commands would verify installed driver version
$ nvidia-smi
$ nvcc -V
  • Go to NVIDIA_CUDA-9.0_Samples/1_Utilities/deviceQuery and make files. After running file, when the driver information is shown property, graphic driver is properly installed!

Unistallation and enable Nouveau


  • To uninstall the CUDA Toolkit, run the uninstallation script provided in the bin directory of the toolkit. By default, it is located in /usr/local/cuda-9.0/bin :
$ sudo /usr/local/cuda-9.0/bin/uninstall_cuda_9.0.pl
  • To uninstall the NVIDIA Driver, run nvidia-uninstall :
$ sudo /usr/bin/nvidia-uninstall
  • To enable the Nouveau drivers, remove the blacklist file created in the Disabling Nouveau section, and regenerate the kernel initramfs/initrd again as described in that section.
Courtesy:

  1. https://developer.nvidia.com/compute/cuda/9.0/Prod/docs/sidebar/CUDA_Installation_Guide_Linux-pdf
  2. https://blog.nelsonliu.me/2017/04/29/installing-and-updating-gtx-1080-ti-cuda-drivers-on-ubuntu/
  3. https://askubuntu.com/questions/149206/how-to-install-nvidia-run
  4. https://github.com/tegg89/installation-1080ti
  5. https://askubuntu.com/questions/210884/setting-ld-library-path-for-cuda