Setting up deep learning environment frameworks, GPU acceleration, or high-performance C++ applications on Linux often requires installing NVIDIA CUDA Toolkit. If you are running Ubuntu 26.04 LTS (Noble Numbat / Future LTS), this step-by-step guide will walk you through downloading, installing, and permanently configuring the CUDA PATH environment variables.
- Prerequisites
- Step 1: System Preparation & Update
- Step 2: Add NVIDIA CUDA Repository & Pinning
- Step 3: Download and Install CUDA 13.3 Package
- Step 4: Update APT and Install CUDA Toolkit
- Step 5: Set CUDA PATH Environment Variables (Crucial Step)
- Step 6: Verify the Installation
- Troubleshooting & Common Issues
- Conclusion
Before proceeding, ensure that:
- You have an NVIDIA GPU installed in your machine.
- You are running Ubuntu 26.04 (x86_64 architecture).
- You have
sudoadministrative privileges. - Proper NVIDIA display drivers are installed (
nvidia-smishould run successfully).
To check your GPU and current driver status, run:
nvidia-smiStart by ensuring your system packages and repository headers are up to date.
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y build-essential dkms wget software-properties-commonAPT repository pinning ensures that system package updates don't unexpectedly overwrite or conflict with official CUDA packages provided directly by NVIDIA.
Execute the following commands to download and configure the repository pin:
# Download the APT repository pin file
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64/cuda-ubuntu2604.pin
# Move the pin file to APT preferences
sudo mv cuda-ubuntu2604.pin /etc/apt/preferences.d/cuda-repository-pin-600Next, download the local installer Debian package (.deb) for CUDA 13.3 on Ubuntu 26.04.
# Download the CUDA local repository package
wget https://developer.download.nvidia.com/compute/cuda/13.3.1/local_installers/cuda-repo-ubuntu2604-13-3-local_13.3.1-610.43.02-1_amd64.deb
# Install the repository package using dpkg
sudo dpkg -i cuda-repo-ubuntu2604-13-3-local_13.3.1-610.43.02-1_amd64.deb
# Copy the GPG keyring to APT's trusted keyrings directory
sudo cp /var/cuda-repo-ubuntu2604-13-3-local/cuda-*-keyring.gpg /usr/share/keyrings/Now that the local repository and keyring are properly configured, update package lists and install cuda-toolkit-13-3:
# Update local package index
sudo apt-get update
# Install CUDA Toolkit 13.3
sudo apt-get -y install cuda-toolkit-13-3Note: If you also need the full display drivers included alongside the toolkit, you can install
sudo apt-get -y install cudainstead of justcuda-toolkit-13-3.
By default, installing the CUDA Toolkit places binaries in /usr/local/cuda-13.3/bin and libraries in /usr/local/cuda-13.3/lib64. However, Linux will not automatically recognize commands like nvcc until you update your shell environment variables.
To temporarily add CUDA to your current terminal session:
export PATH=/usr/local/cuda-13.3/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-13.3/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}To ensure CUDA paths are available every time you open a terminal or log in, append the variables to your ~/.bashrc file (or ~/.zshrc if using Zsh):
# Open bash profile
echo '' >> ~/.bashrc
echo '# NVIDIA CUDA 13.3 Environment Setup' >> ~/.bashrc
echo 'export PATH=/usr/local/cuda-13.3/bin${PATH:+:${PATH}}' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-13.3/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc
# Reload bashrc configuration
source ~/.bashrcAlternatively, you can use symlinks pointing to /usr/local/cuda so that future version upgrades don't break your configuration:
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}For system-wide CUDA dynamic library access across all users:
echo "/usr/local/cuda-13.3/lib64" | sudo tee /etc/ld.so.conf.d/cuda-13-3.conf
sudo ldconfigAfter setting your environment variables, verify that CUDA compiler and driver communications work properly:
nvcc --versionExpected Output:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2026 NVIDIA Corporation
Built on ...
Cuda compilation tools, release 13.3, V13.3.x
which nvccExpected Output: /usr/local/cuda-13.3/bin/nvcc (or /usr/local/cuda/bin/nvcc)
nvidia-smi- Cause: The
PATHenvironment variable is not updated or current shell session was not reloaded. - Fix: Run
source ~/.bashrcor verify that export lines are in~/.bashrc.
- Cause: Interrupted package installations or missing dependencies.
- Fix: Run
sudo apt-get install -fto repair broken dependencies.
- Cause: Kernel updated without DKMS rebuilding modules.
- Fix: Reboot system (
sudo reboot) or reinstall driver packages.
# 1. Download Repository Pinning
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64/cuda-ubuntu2604.pin
sudo mv cuda-ubuntu2604.pin /etc/apt/preferences.d/cuda-repository-pin-600
# 2. Download & Install Repository
wget https://developer.download.nvidia.com/compute/cuda/13.3.1/local_installers/cuda-repo-ubuntu2604-13-3-local_13.3.1-610.43.02-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2604-13-3-local_13.3.1-610.43.02-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2604-13-3-local/cuda-*-keyring.gpg /usr/share/keyrings/
# 3. Install Toolkit
sudo apt-get update
sudo apt-get -y install cuda-toolkit-13-3
# 4. Set PATH Permanently
echo 'export PATH=/usr/local/cuda-13.3/bin${PATH:+:${PATH}}' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-13.3/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc
source ~/.bashrc
# 5. Verify
nvcc --versionYou have successfully installed CUDA Toolkit 13.3 on Ubuntu 26.04 LTS and properly configured environment PATH variables! You are now ready to compile CUDA programs, run GPU acceleration frameworks like PyTorch and TensorFlow, or build custom C++/CUDA kernels.



Comments
Post a Comment