diff --git a/nvidia.sh b/nvidia.sh new file mode 100644 index 0000000..31425eb --- /dev/null +++ b/nvidia.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# Exit immediately if a command exits with a non-zero status. +set -e + +# --- 1. NVIDIA Graphics Driver Installation --- +echo "▶️ Section 1: Installing NVIDIA Graphics Driver..." +echo " This will automatically detect and install the recommended driver." +sudo apt update +sudo ubuntu-drivers autoinstall + +echo "✅ NVIDIA driver installation command issued." +echo " A reboot will be required later for it to take effect." + +# --- 2. CUDA Toolkit Installation --- +echo "▶️ Section 2: Setting up and Installing CUDA Toolkit..." + +# Clean up any previous attempts to avoid conflicts +rm -f cuda-keyring_*.deb + +# Set up the NVIDIA CUDA repository +# These commands are for x86_64 architecture on Ubuntu 22.04 (which ZorinOS 17 is based on) +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-get update + +# Clean up the downloaded deb file +rm -f cuda-keyring_1.1-1_all.deb + +echo "▶️ Installing the CUDA Toolkit (this includes cuBLAS)..." +# The 'cuda' package installs the latest stable version. +sudo apt-get install -y cuda + +# --- 3. cuDNN Library Installation --- +echo "▶️ Section 3: Installing cuDNN Library..." +# These packages provide the runtime and developer libraries for cuDNN +sudo apt-get install -y libcudnn8 libcudnn8-dev + +echo "✅ CUDA and cuDNN have been installed." + +# --- 4. Environment Configuration --- +echo "▶️ Section 4: Configuring environment variables in ~/.bashrc..." + +# Check if the CUDA paths are already in .bashrc to avoid duplicates +if ! grep -q 'export PATH=/usr/local/cuda/bin' ~/.bashrc; then + echo '' >>~/.bashrc + echo '# Add NVIDIA CUDA Toolkit to PATH' >>~/.bashrc + echo 'export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}' >>~/.bashrc + echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >>~/.bashrc + echo "✅ CUDA environment variables added to ~/.bashrc." +else + echo "✅ CUDA environment variables already configured in ~/.bashrc." +fi + +# --- 5. Final Instructions --- +echo "" +echo "------------------------------------------------------------------" +echo "🎉 NVIDIA Stack Installation Complete!" +echo "" +echo " IMPORTANT: You MUST reboot your system for the new NVIDIA" +echo " driver to be loaded correctly." +echo "" +echo " After rebooting, open a new terminal for all changes to take" +echo " effect. You can verify the installation by running:" +echo " nvidia-smi" +echo " nvcc --version" +echo "------------------------------------------------------------------" \ No newline at end of file