Instantly share code, notes, and snippets.

What would you like to do?
Nvidia CUDA Toolkit Installation (Ubuntu 16.04 LTS) - Notes

Successfully installed Nvidia CUDA toolkit (which includes Nvidia driver) to Ubuntu 16.04 LTS on 30th May 2017 - here are some notes for sharing.

Major learning:

  • Disable Secure Boot at UEFI Firmware setting (do this in BIOS mode / restart from Windows advanced startup). (I did try for ages hoping I could get it working with Secure Boot enabled. No luck Secure Boot stopped the Nvidia driver from installing properly on Ubuntu. Disabling Secure Boot turns out to be the only working solution for me - if you are able to get Nvidia driver installed without having to disable Secure Boot, do let me know)
  • Follow the Linux CUDA Installation Guide.
  • (opinionated...) Use the Linux .deb (package manager) installation (for simplicity.). Download the .deb file in a browser. Install from terminal command line.
  • (opinionated...) Don't use runfile installation (too complicated).

Download the Ubuntu package

  • Download here.
  • Linux -> x86_64 -> Ubuntu -> 16.04 -> deb (local)
  • Do checksum to ensure package is downloaded correctly. i.e. md5sum xxx.deb should output the same string as the one published in

Do the pre-installation checks:

Verify computer is Nvidia driver / toolkit compatible.

johnny@johnny-XPS-8700:~$ lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation GM107 [GeForce GTX 750 Ti] (rev a2)
01:00.1 Audio device: NVIDIA Corporation Device 0fbc (rev a1)

Following tells you which Nvidia toolkit to download (Ubuntu x86_64). Verify if compatible.

johnny@johnny-XPS-8700:~$ uname -m && cat /etc/*release
VERSION="16.04.2 LTS (Xenial Xerus)"
PRETTY_NAME="Ubuntu 16.04.2 LTS"

Verify GCC version is installed...

johnny@johnny-XPS-8700:~$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

Verify correct kernel and header.

johnny@johnny-XPS-8700:~$ uname -r

The kernel headers and development packages for the currently running kernel can be installed with:

johnny@johnny-XPS-8700:~$ sudo apt-get install linux-headers-$(uname -r)
[sudo] password for johnny: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
linux-headers-4.8.0-53-generic is already the newest version (4.8.0-53.56~16.04.1).
0 to upgrade, 0 to newly install, 0 to remove and 175 not to upgrade.

Do the Installation

sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda

Reboot to take effect.

sudo reboot

Post Installation Actions

Create / update the environmental variables PATH and LD_LIBRARY_PATH. To make this change permenantly, do a `gedit ~/.profile', add the following lines at the bottom:

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

Note that cuda in the path name actually is a symbolic link points to cuda-8.0 (in my case).

Save the file, log out and log in to take effect.

Once logged back in, do some more checks...

johnny@johnny-XPS-8700:~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61
johnny@johnny-XPS-8700:~$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  375.39  Tue Jan 31 20:47:00 PST 2017
GCC version:  gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 

Copy sample files from a root owned (read only) area to a user specific writable area (say, ~/jccuda).

johnny@johnny-XPS-8700:~$ ~/jccuda

Navigate to ~/jccuda/NVIDIA_CUDA-8.0_Samples. Issue make to compile some files. (there will be lots of warning and some errors. Not critical).

When done, go to ~/jccuda/NVIDIA_CUDA-8.0_Samples/bin/x86_64/linux/release and test out some commands.

deviceQuery should produce something meaningful...

johnny@johnny-XPS-8700:~/jccuda/NVIDIA_CUDA-8.0_Samples/bin/x86_64/linux/release$ ./deviceQuery
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GTX 750 Ti"
  CUDA Driver Version / Runtime Version          8.0 / 8.0
  CUDA Capability Major/Minor version number:    5.0
  Total amount of global memory:                 1998 MBytes (2094530560 bytes)
  ( 5) Multiprocessors, (128) CUDA Cores/MP:     640 CUDA Cores
  GPU Max Clock rate:                            1084 MHz (1.08 GHz)
  Memory Clock rate:                             2700 Mhz
  Memory Bus Width:                              128-bit
  L2 Cache Size:                                 2097152 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GeForce GTX 750 Ti
Result = PASS

bandwidthTest should run...

johnny@johnny-XPS-8700:~/jccuda/NVIDIA_CUDA-8.0_Samples/bin/x86_64/linux/release$ ./bandwidthTest 
[CUDA Bandwidth Test] - Starting...
Running on...

 Device 0: GeForce GTX 750 Ti
 Quick Mode

 Host to Device Bandwidth, 1 Device(s)
 PINNED Memory Transfers
   Transfer Size (Bytes)	Bandwidth(MB/s)
   33554432			12211.7

 Device to Host Bandwidth, 1 Device(s)
 PINNED Memory Transfers
   Transfer Size (Bytes)	Bandwidth(MB/s)
   33554432			12430.5

 Device to Device Bandwidth, 1 Device(s)
 PINNED Memory Transfers
   Transfer Size (Bytes)	Bandwidth(MB/s)
   33554432			70258.7

Result = PASS

NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

Looks good!

In addiiton, search for nvidia at the Ubuntu search button (top left) should show some Nvidia apps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment