Installing NVIDIA drivers and CUDA 8

First off, you need to install the correct NVIDIA driver based on your GPU. I have a GeForce GTX 960M GPU, so I will go ahead and install nvidia-375 (if you have a different GPU, you can use the NVIDIA search tool http://www.nvidia.com/Download/index.aspx to help you find your correct driver version). If you want to know your machine's GPU, you can issue the following command in the terminal:

lspci | grep -i nvidia

You should get the following output in the terminal:

Next, we need to add a proprietary repository of NVIDIA drivers to be able to install the drivers using apt-get:

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-375

After successfully installing the NVIDIA drivers, restart the machine. To verify whether the drivers installed correctly, issue the following command in the Terminal:

cat /proc/driver/nvidia/version

You should get the following output in the Terminal:

Next, we need to install CUDA 8. Open the following CUDA download link: https://developer.nvidia.com/cuda-downloads. Select your operating system, architecture, distribution, version, and finally, installer type as per the following screenshot:

The installer file is about 2 GB. You need to issue the following installation instructions:

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

Next, we need to add the libraries to the .bashrc file by issuing the following commands:

echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc

Next, you need to verify the installation of CUDA 8 by issuing the following command:

nvcc -V

You should get the following output in the terminal:

Finally, in this section, we need to install cuDNN 6.0. The NVIDIA CUDA Deep Neural Network library (cuDNN) is a GPU-accelerated library of primitives for deep neural networks. You can download it from NVIDIA's web page. Issue the following commands to extract and install cuDNN:

cd ~/Downloads/
tar xvf cudnn*.tgz
cd cuda
sudo cp */*.h /usr/local/cuda/include/
sudo cp */libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

To ensure that your installation has been successful, you can use the nvidia-smi tool in the terminal. If you had a successful installation, this tool will provide you with a monitoring information such as RAM and the running process for your GPU.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset