In this short tutorial I’ll show you how to easily install the CUDA libraries and cuDNN for both Windows 10 and Ubuntu 14.04 (I installed it only on this two os but it should work also on Ubuntu 16.04 and 17.04). I’ll show also some usefull scripts that can help you a bit while doing heavy GPU computing. If you want to know what are the best graphic cards for GPU computing with CUDA, here is a list of them.
1. On Ubuntu
1.1. CUDA installation
The installation on the two different versions of ubuntu are very similar. If you are using ubuntu 16.04 or 17.04 have just to download the .deb package from the cuda download page, by selecting “Linux”, “x86_64”, “Ubuntu”, “16.04” or “17.04” depending on your version, “deb (local)”. If you have Ubuntu 14.04, download here the .zip archive which contain two versions of CUDA for Ubuntu 14.04, 8.0 and 9.0.
Once you downloaded the correct .deb package, open a terminal and type:
sudo dpkg -i cuda-repo-ubuntuxxxx-x-x-local_x.x.xx_amd64.deb
sudo apt-get update
sudo apt-get install cuda
And replace the “xx” characters with the correct name of the package. Once you installed this libraries, you are ready to install the cuDNN ones.
1.2. cuDNN installation
cuDNN installation on Ubuntu is very easy and quick. You just need to go on the nvidia cudnn download page, click on the “Download” button, create an account in order to download the libs. Choose the last version compatible with your CUDA distribution, in my case,
Download cuDNN v7.0.4 (Nov 13, 2017), for CUDA 9.0
In the drop-down menu choose:
cuDNN v7.0.4 Library for Linux
Once you have done, download the archive. Untar the downloaded file typing in the terminal:
tar -xvzf cudnn-9.0-linux-x64-v7.tgz
You should get a folder called “cuda”. Now you have to add it to the local libs:
cd ~/Downloads/cuda
sudo cp lib64/* /usr/local/cuda/lib64/
sudo cp include/cudnn.h /usr/local/cuda/include/
1.3. Updating the .bashrc file
I found on this github page this configuration to add at the end of the .bashrc in you home.
Just type:
gedit ~/.bashrc
And at the end of the file add:
# add cuda tools to command path
export PATH=/usr/local/cuda/bin:${PATH}
export MANPATH=/usr/local/cuda/man:${MANPATH}
# add cuda libraries to library path
if [[ "${LD_LIBRARY_PATH}" != "" ]]
then
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
else
export LD_LIBRARY_PATH=/usr/local/cuda/lib64
fi
1.4. Useful tools
You can use some tools to get more infos about our graphic card. I found this tool called gmonitor that helps you to monitor the GPU usage of your nvidia card. To use it, just clone the repository with
git clone https://github.com/mountassir/gmonitor.git
Than, you can compile it and run with
cd gmonito-master/src
make
./gmonitor
2. On Windows
2.1. CUDA installation
On windows, the installation is easier. You only have to download the driver for the official cuda download page, by selecting “Windows”, “x86_64”, “10” or “8.1” depending on your version, “exe (local)”. Just double-click on it and install it giving administrator premissions.
2.2. cuDNN installation
Installing the cuDNN is very similar to the Ubuntu installation: you just need to go on the nvidia cudnn download page, click on the “Download” button, create an account in order to download the libs. Choose the last version compatible with your CUDA distribution, in my case,
Download cuDNN v7.0.4 (Nov 13, 2017), for CUDA 9.0
In the drop-down menu choose:
cuDNN v7.0.4 Library for Windows 10
Unzip the .zip archive and copy the following files:
- cuda\bin\cudnn64_7.dll –> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin
- cuda\include\cudnn.h –> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include
- cuda\lib\x64\cudnn.lib –> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64
Endly, you have to add the CUDA path to the enivroments variables. To do so, run the command:
control sysdm.cpl
cuda Select the ** Advanced ** tab, click on the Enviroments Variables at the end of the window and ensure that these values are set:
Variable Name: CUDA_PATH
Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0
You are good to go.
2.3. Useful tools
In order to monitor my GPU I used the MSI AfterBurner tool, which you can download for free for here. I found it very simple to use and you can also overclock your GPU from here.
To find how many CUDA cores your GPU has, you can use CUDA-Z, very simple but useful at the same time.
If you have some questions or you found some imprecisions in this article, tell me in the comments below.
February 21, 2018 at 6:17 pm
I’m not that much of a online reader to be honest but your blogs really nice, keep it up! I’ll go ahead and bookmark your site to come back later. Many thanks|
February 22, 2018 at 6:13 am
Thank you so much!
February 21, 2018 at 11:39 pm
When someone writes an piece of writing he/she keeps the plan of a user in his/her mind that how a user can be aware of it. So that’s why this article is great. Thanks!|
May 3, 2018 at 5:50 pm
I simply want to mention I am newbie to weblog and actually enjoyed you’re web page. Most likely I’m want to bookmark your website . You absolutely have wonderful articles. Thank you for sharing your website.
May 9, 2018 at 11:43 am
I simply want to tell you that I am just newbie to blogging and site-building and honestly savored your web-site. Probably I’m want to bookmark your site . You definitely have remarkable posts. Appreciate it for sharing your webpage.
November 23, 2018 at 3:52 am
oke thanks for information and solution