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¶
This installs CUDA to /usr/local/cuda-12.1/.
3. Create Symlinks to System Paths¶
# 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-toolkitpackage layout. - Compatible with existing workflows that expect
nvccin/usr/bin.