CUDA installation
TIP
You don’t need to use sudo to install CUDA Toolkit and cuDNN.
CUDA 13.2
In this example we will use ${HOME}/cuda-13.2.0 as our installation path.
bash
cd "${HOME}"Download CUDA runfile installer:
bash
wget https://developer.download.nvidia.com/compute/cuda/13.2.0/local_installers/cuda_13.2.0_595.45.04_linux.runUpdate permissions:
bash
chmod +x ./cuda_13.2.0_595.45.04_linux.runStart the runfile installation (takes a few quiet minutes):
bash
./cuda_13.2.0_595.45.04_linux.run \
--silent \
--toolkit \
--installpath=${HOME}/cuda-13.2.0 \
--no-opengl-libs \
--no-drm \
--no-man-page && echo Success || echo FailCleanup installation files:
bash
rm -v cuda_13.2.0_595.45.04_linux.runInstall cuDNN for CUDA 13.2
Download cuDNN package:
bash
wget https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-9.20.0.48_cuda13-archive.tar.xzExtract the cuDNN package into our cuda installation:
bash
tar -xvf cudnn-linux-x86_64-9.20.0.48_cuda13-archive.tar.xz --strip-components=1 -C ${HOME}/cuda-13.2.0 && echo Success || echo FailAfter extraction, remove the package:
bash
rm -v cudnn-linux-x86_64-9.20.0.48_cuda13-archive.tar.xzCreate activation script for CUDA 13.2
TIP
In the activation script have used the CUDA installation directory from our example above (${HOME}/cuda-13.2.0)
Create activation script by running the code below:
bash
cat <<\EOF > ~/activate-cuda-13.2.0.sh
export CUDA_HOME=${HOME}/cuda-13.2.0
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$CUDA_HOME/extras/CUPTI/lib64:$LD_LIBRARY_PATH
export CUDAToolkit_ROOT_DIR=$CUDA_HOME
export CUDAToolkit_ROOT=$CUDA_HOME
export CUDA_TOOLKIT_ROOT_DIR=$CUDA_HOME
export CUDA_TOOLKIT_ROOT=$CUDA_HOME
export CUDA_BIN_PATH=$CUDA_HOME
export CUDA_PATH=$CUDA_HOME
export CUDA_INC_PATH=$CUDA_HOME/targets/x86_64-linux
export CFLAGS=-I$CUDA_HOME/targets/x86_64-linux/include:$CFLAGS
export CUDAToolkit_TARGET_DIR=$CUDA_HOME/targets/x86_64-linux
EOFSet environment variables for CUDA 13.2
From now one you can easily load your cuda variables by sourcing activation script:
bash
source ~/activate-cuda-13.2.0.shTest commands
Run test commands to confirm that your installation was successful:
bash
which nvcc
nvcc --versionThe expected output:
text
/home/ubuntu/cuda-13.2.0/bin/nvcc
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2026 NVIDIA Corporation
Built on Mon_Mar_02_09:52:23_PM_PST_2026
Cuda compilation tools, release 13.2, V13.2.51
Build cuda_13.2.r13.2/compiler.37434383_0