Skip to content

Latest commit

 

History

History

cuda_toolkit

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

How to install nvidia CUDA Toolkit on Linux system

Source: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html

All version doc: https://developer.nvidia.com/cuda-toolkit-archive

Download: http://developer.nvidia.com/cuda-downloads

NOTE 1: this guide is best for installing from fresh (no previous installation) & support install multiple version of cuda toolkit

NOTE 2: we can install multiple version of cuda toolkit on the same system but can only run one of them at a time. A tip for switching between different versions is mentioned below

Table of contents

Pre-installation steps

Step 1: Install nvidia driver

NOTE: For choosing nvidia driver according to target cuda toolkit version, refer to cuda toolkit release notes - Table 3. CUDA Toolkit and Corresponding Driver Versions

Step 2: Check for maximum supported cuda toolkit version according to installed driver

nvidia-smi

Ex:

nvidia-smi

any cuda toolkit version <= 11.2 is compatiple with current system

Ubuntu 18.04

Method 1 (runfile)

Step 1: Download cuda toolkit runfile (version according to above pre-installation steps) from nvidia websites

Step 2: Go to download folder & run the installation file

NOTE: Remember to exclude driver installation included in the runfile

sudo sh <runfile>.run

Cuda toolkit download page

Method 2 (using pakage manager offline)

Follow instruction on download page Cuda toolkit download page

Method 3 (using pakage manager online)

Follow instruction on download page Cuda toolkit download page

Post-installation steps

Configure symlink for cuda toolkit version

Create symlink from /usr/local/cuda to /usr/local/cuda-<version> (remove existing cuda symlink if necessary)

sudo ln -s /usr/local/cuda-<version> /usr/local/cuda

NOTE: This is also used for switching between version of cuda toolkit

Configure PATH

Check the name of nsight-compute in cuda toolkit installed directory Cuda toolkit directory

Modify & add these lines accordingly to ~/.bashrc or ~/.profile (for local users) or /etc/profile (for system-wide users) & restart terminal/OS

if [ -d "/usr/local/cuda/bin/" ]; then
    export PATH=/usr/local/cuda/bin:/usr/local/cuda/nsight-compute-<version>${PATH:+:${PATH}}
fi

Configure LD_LIBRARY_PATH

Add /usr/local/cuda/lib64 to /etc/ld.so.conf.d/<cuda_config>.conf file and run ldconfig as root

sudo bash -c "echo /usr/local/cuda/lib64 > /etc/ld.so.conf.d/cuda.conf"
sudo ldconfig

NOTE: Later version of cuda toolkit installer has done this so no need to (/etc/ld.so.conf.d/cuda-<version>.conf)

CentOS 7

Method 1 (runfile)

Same as runfile on Ubuntu

Method 2 (using pakage manager offline)

Follow instruction on download page Cuda toolkit download page

NOTE: Remove nvidia-driver-latest-dkms since driver has been installed

Method 3 (using pakage manager online)

Follow instruction on download page Cuda toolkit download page

NOTE: Remove nvidia-driver-latest-dkms since driver has been installed

Post-installation steps

Configure symlink for cuda toolkit version

Same as ubuntu version

Configure PATH

Add file <cuda_PATH_conf>.sh to /etc/profile.d/ with below content Cuda toolkit directory

if [ -d "/usr/local/cuda/bin/" ]; then
    pathmunge /usr/local/cuda/bin
    pathmunge /usr/local/cuda/nsight-compute-<version>
fi

Configure LD_LIBRARY_PATH

Same as ubuntu version

Checking installation

Run below command to check for installed & running version:

nvcc --version

Cuda toolkit check

ll /usr/local/

Cuda toolkit check

A symlink created to re-direct any access to cuda to current in-use version

Uninstall

To uninstall, take reference from installation guide in accordance with your installation method.

For unintall tar file method, if uninstaller file not exist, go to release section of this repo & download it from there.