Guide
An installation guide to take you through the NVIDIA graphics driver as well as CUDA toolkit setup on an Ubuntu 18.04 LTS.
A. Know your cards
Verify what graphics card you have on your machine
rahul@karma:~$ lspci | grep VGA 04:00.0 VGA compatible controller: NVIDIA Corporation GM204 [GeForce GTX 970] (rev a1)
rahul@karma:~$ sudo lshw -C video *-display description: VGA compatible controller product: GM204 [GeForce GTX 970] vendor: NVIDIA Corporation physical id: 0 bus info: pci@0000:04:00.0 version: a1 width: 64 bits clock: 33MHz capabilities: pm msi pciexpress vga_controller bus_master cap_list rom configuration: driver=nouveau latency=0 resources: irq:30 memory:f2000000-f2ffffff memory:e0000000-efffffff memory:f0000000-f1ffffff ioport:2000(size=128) memory:f3080000-f30fffff
Download the right driver
downloaded the Version 390.67 for GeForce GTX 970
B. Nouveau problem kills your GPU rush
Hoever there are solutions available
Here is what worked for me
- remove all nvidia packages ,skip this if your system is fresh installed
sudo apt-get remove nvidia* && sudo apt autoremove
- install some packages for build kernel:
sudo apt-get install dkms build-essential linux-headers-generic
- now block and disable nouveau kernel driver:
sudo vim /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
Insert follow lines to the nvidia-installer-disable-nouveau
.conf:
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
save and exit.
- Disable the Kernel nouveau by typing the following commands(
nouveau-kms.conf
may not exist,it is ok):rahul@wind:~$ echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf options nouveau modeset=0
- build the new kernel by:
rahul@wind:~$ sudo update-initramfs -u update-initramfs: Generating /boot/initrd.img-4.15.0-23-generic
- reboot
$ sudo init 3 $ sudo bash $ ./NVIDIA-Linux-x86_64-390.67.run
Uninstall
C. NVIDIA X Server Settings

D. Start the CUDA related setup
- Samba server share for all the file share.
- A list of the CUDA toolkit versions against the GPU architecture is invaluably listed here.
- Download the CUDA compute 3.0 compatible toolkit.
We will need the CUDA toolkit 9.1 which is supported for the GTX 970 version with compute 3.0 capability. So download the local installer for Ubuntu.
Downloaded the “cuda_9.1.85_387.26_linux.run*” local installation file.
$ sudo add-apt-repository ppa:graphics-drivers/ppa $ sudo apt install nvidia-cuda-toolkit gcc-6
Steps are taken from the CUDA 9.1 official documentation
- Perform the pre-installation actions.
- Disable the Nouveau drivers. We did this in the above driver installation
- Reboot into text mode (runlevel 3). This can usually be accomplished by adding the number “3” to the end of the system’s kernel boot parameters. Change the runlevel ‘sudo init 3’, refer
- Verify that the Nouveau drivers are not loaded. If the Nouveau drivers are still loaded, consult your distribution’s documentation to see if further steps are needed to disable Nouveau.
- Run the installer and follow the on-screen prompts:
$ chmod +x cuda_9.1.85_387.26_linux $ rahul@wind:~/Downloads$ ./cuda_9.1.85_387.26_linux --override
Since we already installed the Driver above we say NO in the NVIDIA accelerated graphic driver installation question.
This will install the CUDA stuff in the following locations
- CUDA Toolkit /usr/local/cuda-9.1
- CUDA Samples $(HOME)/NVIDIA_CUDA-9.1_Samples
We can verify the graphic card using the NVIDIA-SMI command.
Uninstallation
cd /usr/local/cuda-9.1/bin
sudo ./uninstall_cuda_9.1.pl
E. Environment Variables
rahul@wind:~$ vim ~/.bashrc # Add the following to the environment variables export PATH=/usr/local/cuda-9.1/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda-9.1/lib64 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda-9.1/lib rahul@wind:~$ source ~/.bashrc rahul@wind:~$ nvcc --version nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2018 NVIDIA Corporation Built on Tue_Jun_12_23:07:04_CDT_2018 Cuda compilation tools, release 9.1,
F. Test
Ensure you have the right driver versions
rahul@wind:$ cat /proc/driver/nvidia/version NVRM version: NVIDIA UNIX x86_64 Kernel Module 390.67 Fri Jun 1 04:04:27 PDT 2018 GCC version: gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)
Change directory to the NVIDIA CUDA Samples and compile them
rahul@wind:~/NVIDIA_CUDA-9.1_Samples$ make
Now run the device query test
rahul@wind:~/NVIDIA_CUDA-9.1_Samples/bin/x86_64/linux/release$ ./deviceQuery ./deviceQuery Starting... CUDA Device Query (Runtime API) version (CUDART static linking)
END