Skip to content

๐Ÿš€ CUDA Toolkit Installation Guide

Amir M. Parvizi edited this page Nov 19, 2024 · 2 revisions

๐ŸŽฏ Prerequisites

Hardware Requirements
Component Minimum Recommended
GPU NVIDIA Kepler+ NVIDIA Ampere/Hopper
RAM 4GB 16GB+
Disk Space 2.5GB 10GB
CPU x86_64 Multi-core x86_64
Software Requirements
graph LR
    A[Operating System] --> B[Linux/Windows]
    B --> C[Compatible Driver]
    C --> D[Development Tools]
Loading
  • ๐Ÿ–ฅ๏ธ Operating System
    • Linux: Kernel 3.10+
    • Windows: 10/11
  • ๐Ÿ”ง Development Tools
    • GCC 7+ (Linux)
    • MSVC 2019+ (Windows)
  • ๐ŸŽฎ NVIDIA Driver: 525.0.0+

๐Ÿ“ฆ Installation

Linux Installation

Quick Install (Recommended)
# Download CUDA Toolkit
wget https://developer.download.nvidia.com/compute/cuda/12.6.0/local_installers/cuda_12.6.0_535.54.03_linux.run

# Install
sudo sh cuda_12.6.0_535.54.03_linux.run
Package Manager Install
# For Ubuntu/Debian
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /"
sudo apt update
sudo apt install cuda-toolkit-12-6

Windows Installation

Network Installer
  1. Download the CUDA Network Installer
  2. Run the installer
  3. Follow the wizard ๐Ÿง™โ€โ™‚๏ธ

๐Ÿ”ง Environment Setup

Add these to your shell configuration file (~/.bashrc, ~/.zshrc, etc.):

# CUDA Toolkit Path
export CUDA_HOME=/usr/local/cuda-12.6
export PATH="$CUDA_HOME/bin:$PATH"
export LD_LIBRARY_PATH="$CUDA_HOME/lib64:$LD_LIBRARY_PATH"
๐Ÿ“ Optional Environment Variables
# Optional: CUDA device order
export CUDA_DEVICE_ORDER=PCI_BUS_ID

# Optional: Default device
export CUDA_VISIBLE_DEVICES=0

# Optional: CUDA cache path
export CUDA_CACHE_PATH="$HOME/.cuda-cache"

โœ… Verification

# Check CUDA compiler
nvcc --version

# Check NVIDIA driver
nvidia-smi

# Run sample test
cd $CUDA_HOME/samples/1_Utilities/deviceQuery
make
./deviceQuery

Expected Output:

๐Ÿ“Š CUDA Device Query Results:  CUDA Version: 12.6
  Driver Version: 535.54.03  CUDA Capability: x.y  ...

๐Ÿ” Troubleshooting

Common Issues
Issue Solution
nvcc: command not found Check PATH variable
Driver version mismatch Update NVIDIA driver
Installation fails Check system requirements
CUDA not found Verify environment variables
Diagnostic Commands
# Check CUDA installation
ls -l /usr/local/cuda

# Check driver status
systemctl status nvidia-driver

# Check GPU detection
lspci | grep -i nvidia

๐Ÿš€ Advanced Configuration

Multi-GPU Setup
# List all GPUs
nvidia-smi -L

# Set specific GPUs
export CUDA_VISIBLE_DEVICES=0,1

# Check GPU utilization
nvidia-smi -l 1
Performance Optimization
  • Enable persistence mode
sudo nvidia-smi -pm 1
  • Set GPU clock speeds
sudo nvidia-smi -ac 5001,1590

๐Ÿ“š Additional Resources