In this blog, I will demonstrate how to install CUDA 10.0 library in Ubuntu 18.04
Note: The process mentioned here should work for other versions of the CUDA library and should also work for other versions of the Ubuntu Operating System
Step 1: Install Nvidia GPU driver
Make sure to install the latest Nvidia driver or compatible Nvidia driver for CUDA 10.0. You can check which Nvidia driver is compatible with CUDA 10.0 from here
$ sudo add-apt-repository ppa:graphics-drivers
$ sudo apt-get update
$ sudo apt-get install nvidia-driver-450
Restart the machine and check if Nvidia drivers are successfully installed by issuing the following command
Note: Don’t panic by seeing CUDA 11.0 (or other CUDA version) at the top right corner in the above output. It does not represent CUDA installed in the system, there is another command to check the CUDA version installed in the system I will show it later
Step 2: Download CUDA 10.0 library and Patch runfile installer from here by selecting the following options
Step 3: Install CUDA library by running the following command
$ sudo sh cuda_10.0.130_410.48_linux.run
Press and hold ENTER to read the license until 100% and choose the following options
Do you accept the previously read EULA?
accept/decline/quit: acceptYou are attempting to install on an unsupported configuration. Do you wish to continue?
(y)es/(n)o [ default is no ]: yInstall NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
(y)es/(n)o/(q)uit: nInstall the CUDA 10.0 Toolkit?
(y)es/(n)o/(q)uit: yEnter Toolkit Location
[ default is /usr/local/cuda-10.0 ]: ENTERDo you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: yInstall the CUDA 10.0 Samples?
Note: We are not installing the Nvidia driver provided by Installer because generally in Installer older GPU drivers are present and we should always use the latest drivers
If the installation is successful then CUDA will be installed at this path
Step 4: Install Patches by running the following command
$ sudo sh cuda_10.0.130.1_linux.runDo you accept the previously read EULA?
accept/decline/quit: acceptEnter CUDA Toolkit installation directory
[ default is /usr/local/cuda-10.0 ]: ENTER
Step 5: Download cuDNN for cuda CUDA 10.0 from here, you will have to create an Nvidia developer account to download the files
Step 6: Install cuDNN
Unpack the archive
$ tar -zxvf cudnn-10.0-linux-x64-v22.214.171.124.tgz
Copy the unpacked contents to your CUDA directory
$ sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-10.0/lib64/
$ sudo cp cuda/include/cudnn.h /usr/local/cuda-10.0/include/
Give read access to all users
$ sudo chmod a+r /usr/local/cuda-10.0/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
Note: Here I am Installing cuDNN 7.6.5 but you can install other versions of your choice
Step 7: Setup CUDA path by adding the following lines at the end of
$ source ~/.bashrc
Step 8: Check if CUDA is successfully installed
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright © 2005–2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130
Removing CUDA Library:
If you wish to remove the CUDA Library for some reason then remove CUDA paths from
~/.bashrc file and issue the following commands
$ sudo /usr/local/cuda-10.0/bin/uninstall_cuda_10.0.pl
$ sudo rm -r /usr/local/cuda-10.0