Skip to content

GPU / CUDA Toolkit

CUDA 12.1 Installation on Ubuntu (Lambda-Style)

This installs CUDA 12.1 to work like Lambda Labs' nvidia-cuda-toolkit package, where nvcc is in /usr/bin and works everywhere — including SLURM jobs — without additional configuration.

1. Add NVIDIA CUDA Repository

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt update

2. Install CUDA 12.1 Toolkit

sudo apt install cuda-toolkit-12-1

This installs CUDA to /usr/local/cuda-12.1/.

# Link CUDA binaries to /usr/bin
sudo ln -sf /usr/local/cuda-12.1/bin/nvcc /usr/bin/nvcc
sudo ln -sf /usr/local/cuda-12.1/bin/nvprof /usr/bin/nvprof
sudo ln -sf /usr/local/cuda-12.1/bin/nsys /usr/bin/nsys

# Link CUDA libraries to the system library path
sudo ln -sf /usr/local/cuda-12.1/lib64/libcudart.so* /usr/lib/x86_64-linux-gnu/

# Update library cache
sudo ldconfig

4. Verify Installation

# Check nvcc version
nvcc --version

# Should output:
# Cuda compilation tools, release 12.1, V12.1.105

# Test in a SLURM job
sbatch test_cuda.sh

Note

test_cuda.sh isn't a provided file — write a small sbatch script that runs nvcc --version (or a trivial CUDA binary) to confirm it works inside a job, same as outside one.

Notes

  • No environment variables needed (PATH, LD_LIBRARY_PATH, CUDA_HOME).
  • Works automatically in SLURM jobs.
  • Mimics Lambda Labs' nvidia-cuda-toolkit package layout.
  • Compatible with existing workflows that expect nvcc in /usr/bin.