Updating Nvidia CUDA to 8.0.x in Ubuntu 16.04 – EC2 Gx instance

Get Nvidia Cuda compiler version first

$ nvcc –version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Wed_May__4_21:01:56_CDT_2016
Cuda compilation tools, release 8.0, V8.0.26

Check Ubuntu version:
$ lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial

Check NVidia Driver version:
$ nvidia-smi

NVIDIA: API mismatch: the NVIDIA kernel module has version 370.28,
but this NVIDIA driver component has version 304.132. Please make
sure that the kernel module and all NVIDIA driver components
have the same version.
Failed to initialize NVML: Unknown Error

Get updated Nvidia driver from the link below:
Visit: https://developer.nvidia.com/cuda-downloads

Select proper OS version, architecture, distribution, version and installer then download the full driver locally:

screen-shot-2016-11-09-at-10-29-06-pm

Alternatively use the link below to download the 1.9GB driver:

$ wget https://developer.nvidia.com/compute/cuda/8.0/prod/local_installers/cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64-deb

Install the downloaded CUDA 8.0.44 from the local file:
$ sudo dpkg -i cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64-deb
$ sudo apt-get update
$ sudo apt-get -f upgrade
$ sudo apt-get install cuda

Note: If there are errors, retry above commands.

Finally reboot the EC2 Instance or your machine:

$ sudo reboot

Now try your Nvidia version again:
$ nvidia-smi
Thu Nov 10 06:24:00 2016
+———————————————————————–+
| NVIDIA-SMI 367.57 Driver Version: 367.57 |
|——————————-+—————+———————-+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+================+======================|
| 0 GRID K520 Off | 0000:00:03.0 Off | N/A |
| N/A 33C P0 1W / 125W | 0MiB / 4036MiB | 0% Default |
+——————————-+————–+———————-+

+———————————————————————+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|========================================================================|
| No running processes found |
+———————————————————————-+

Upgrading nvidia driver to 370 or above:

$ sudo apt-get install nvidia-370

If above command gives error “Unable to locate package nvidia-370” try the following:

  • $ sudo add-apt-repository ppa:graphics-drivers/ppa
  • $ sudo apt-get update
  • $ sudo apt-get install nvidia-370
  • $ sudo apt-get install nvidia-370-dev

Finally check the Nvidia Compiler version:

$ nvcc –version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Sun_Sep__4_22:14:01_CDT_2016
Cuda compilation tools, release 8.0, V8.0.44

Note: if you still nvcc as 7.5 then do the following:

REBOOT is necessary after update above. 

  1. Check nvcc 8.0 is at /usr/local/cuda/bin
  2. export PATH=${PATH}:/usr/local/cuda/bin
  3. Check path
  4. now check nvcc
Advertisements

One thought on “Updating Nvidia CUDA to 8.0.x in Ubuntu 16.04 – EC2 Gx instance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s