Install CUDA and cuDNN

At the moment there is a big hype about Deep learning. More and more frameworks for neural networks are in the making and getting improved every day. A lot of pretty cool stuff can be done with Neural Networks. GPU computing is a key factor for the success of neural networks. In this tutorial we show you how to set up your Computer for the beautiful world of GPU computing. Therefore we show you how to install CUDA (Compute Unified Device Architecture) and cuDNN (CUDA Deep Neural Network library). This Tutorial is designed for Ubuntu.

Step 1: Check your Hardware

The base for GPU computing is a solid Hardware setup. Not all GPU’s are able to run with CUDA. To find out your hardware configuration run the following command in the terminal.
sudo lshw -c video Check the compute capability of your GPU here. CUDA 8.0 requires at least 3.0.

Step 2: Install the Nvidia driver

To install the Nvidia driver go into the System Settings, then to Software and Updates and navigate to the tab Additional Drivers. Choose the current Nvidia binary Driver (proprietary, tested) and apply the changes. Reboot the computer and check if the installation worked with the following command.
nvidia-smi
The Output should look like this:

If you experience Tearing (horizontal stripes while watching videos) check out our guide about fixing screen tearing.

Step 3: Download and install CUDA

Download the CUDA .run file here and run it. sudo sh <downloaded_file> Follow the instructions on the command line. If you get stuck at the first step, press q and then type accept. When asked to install the driver type no. We already got that part covered. Here is the configuration and output of my Cuda installation.

Do you accept the previously read EULA?
accept/decline/quit: accept

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.48?
(y)es/(n)o/(q)uit: n

Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: y

Enter Toolkit Location
[ default is /usr/local/cuda-8.0 ]:

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: n

Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: n

Installing the CUDA Toolkit in /usr/local/cuda-8.0 …

===========
= Summary =
===========

Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-8.0
Samples: Not Selected

Please make sure that
– PATH includes /usr/local/cuda-8.0/bin
– LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin

Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.

***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 8.0 functionality to work.
To install the driver using this installer, run the following command, replacing with the name of this run file:
sudo .run -silent -driver

Logfile is /tmp/cuda_install_30418.log

To finish the installation add following in your .bashrc or .zshrc file.export PATH=/usr/local/<cuda-yourcudaversion>/bin:$PATH
export LD_LIBRARY_PATH=/usr/local//lib64:$LD_LIBRARY_PATH

For <cuda-yourcudaversion> choose your cuda version e.g. cuda-8.0.
Now source the .bashrc or .zshrc file.source ~./bashrc source ~./zshrc
Check the installation with nvcc −−version

Step 4: Install cuDNN

First download cuDNN. You have to register to get access to the Download. Choose the library for linux. After downloading the file extract the content. tar -zxf <downloaded_file>.tgz Navigate into the folder with the extracted content and copy the following files into your Cuda Folder.
cd cudasudo cp lib64/* <Path_to_your_Cuda>/lib64/sudo cp include/* <Path_to_your_Cuda>/include/
Usually the Cuda Folder ist located in /usr/local/.

That’s it. Hopefully this tutorial answered your questions. If you have any questions just leave a comment. Happy GPU computing.

Leave a Reply

Your email address will not be published. Required fields are marked *

Just another Linux site