How to install CUDA on ubuntu 18.10 ?

Installing NVIDIA related things on linux, what a tedious or boring task ! Because we don’t know, after installation try my ubuntu will start successfully or not ! I know, all time those this will not be happen with everyone but in 90% cases. 😀

You must have NVIDIA GPU on your system. All newly GPU support CUDA Toolkit.

Installation Steps :

Update your ubuntu and install remaining updates. Then after install required kernel packages.

$ sudo apt update && sudo apt upgrade -y
$ sudo apt-get install linux-headers-$(uname -r)

Next step is, remove installed or currently running nvidia drivers. For that go in Software & Updates > Additional Drivers. Choose opensource driver and restart your system.

Now, Download nvidia-driver-418.43. It will be .run file. Open terminal and go in download location and fire below command. Follow options on terminal. One more thing is, install driver as a kernel module. Last, Reboot.

$ sudo chmod 777 
$ sudo sh

Now, check driver is installed correctly or not by firing below command on terminal. If it’s a installed correctly then you can see driver info on terminal.

$ nvidia-smi

Now, download CUDA 10.1 from nvidia site. Installer type choose runfile (local). It’s size approx 2.5GB.

Make sure download is complete and right option was chosen for download.

Open terminal and go to download location and fire below command to install it.

CUDA toolkit installation will take a time. Follow options on terminal. Uncheck nvidia driver option because we already installed it.

$ sudo chmod 777
$ sudo sh

If your CUDA installation failed, check out error in log file. You can find log file path on terminal.

If your installation is success then, you can find message like this on terminal

= Summary =

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-10.1/
Samples:  Installed in /home/shivangpatel/, but missing recommended libraries

Please make sure that
 -   PATH includes /usr/local/cuda-10.1/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-10.1/lib64, or, add /usr/local/cuda-10.1/lib64 to /etc/ and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-10.1/bin

Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-10.1/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 418.00 is required for CUDA 10.1 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run --silent --driver

Logfile is /var/log/cuda-installer.log

This summary message is all about to set librery path for cuda toolkit. We need to set 2 paths. Fire below commands. For the file edit you can use any known editor. I am using Vim. 😀 Make sure you are not root user.

Set PATH first. For that we need to edit .profile file.

$ vim ~/.profile

In end of the .profile file, add one line…

export PATH="$PATH:/usr/local/cuda-10.1/bin"

Now, set LD_LIBRARY_PATH path. For that file.

$ vim /etc/ 

In starting of file add below line.

include /usr/local/cuda-10.1/lib64

Verify CUDA installation :

Now, reboot your system.

To check successful CUDA 10.1 toolkit installation, fire below command.

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:17_PST_2019
Cuda compilation tools, release 10.1, V10.1.105

Ohhh… That’s it ! Installation is done. Enjoy !

Note : If you find any trouble comment below. But it’s a good practice to always check log file and terminal for correct hint!

Recommended Posts

No comment yet, add your voice below!

Add a Comment

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