Installing Nvidia CUDA on Ubuntu 14.04 for GPU Computing
In this article I am going to discuss how to install the Nvidia CUDA toolkit for carrying out high-performance computing (HPC) with an Nvidia Graphics Processing Unit (GPU). CUDA is the industry standard for working with GPU-HPC.
Installation and Testing
The first task is to make sure that you have the GNU compiler collection (GCC) tools installed. This is carried out by installing the build-essential
package:
sudo apt-get install build-essential
I’ll assume that you have a 64-bit system for the remainder of the article. The next step is to download the specific DEB package for the 64-bit version of CUDA for Ubuntu 14.04. I placed this in my home Downloads directory:
cd ~/Downloads wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_6.5-14_amd64.deb
The following commands will install CUDA 6.5:
sudo dpkg -i cuda-repo-ubuntu1404_6.5-14_amd64.deb sudo apt-get update sudo apt-get install cuda
We also need to add the following lines to our .bash_profile
file in our home directory, in order to obtain the required compilation tools on our PATH
:
export PATH=/usr/local/cuda-6.5/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-6.5/lib64:$LD_LIBRARY_PATH
Remember to make sure that the terminal has access to these variables:
source ~/.bash_profile
Before proceeding to test the GPU cards we will ensure that the drivers are correctly installed. The following line will provide us with the driver version:
cat /proc/driver/nvidia/version
The output on my system is as follows
NVRM version: NVIDIA UNIX x86_64 Kernel Module 331.89 Tue Jul 1 13:30:18 PDT 2014 GCC version: gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
Check the version of the Nvidia CUDA compiler:
nvcc -V
The output on my system is as follows
nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2014 NVIDIA Corporation Built on Thu_Jul_17_21:41:27_CDT_2014 Cuda compilation tools, release 6.5, V6.5.12
via: http://www.quantstart.com/articles/Installing-Nvidia-CUDA-on-Ubuntu-14-04-for-Linux-GPU-Computing