Skip to content

Instantly share code, notes, and snippets.

@Ahanio
Last active October 9, 2024 18:22
Show Gist options
  • Select an option

  • Save Ahanio/947593dbc009a772776c32946cd0470b to your computer and use it in GitHub Desktop.

Select an option

Save Ahanio/947593dbc009a772776c32946cd0470b to your computer and use it in GitHub Desktop.

Revisions

  1. Ahanio revised this gist Oct 9, 2024. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions cuda 12.1
    Original file line number Diff line number Diff line change
    @@ -36,10 +36,10 @@ sudo add-apt-repository ppa:graphics-drivers/ppa
    sudo apt update

    # install nvidia driver with dependencies
    sudo apt install libnvidia-common-535
    sudo apt install libnvidia-gl-535
    sudo apt install nvidia-driver-535
    sudo apt install nvidia-dkms-535
    sudo apt install libnvidia-common-550
    sudo apt install libnvidia-gl-550
    sudo apt install nvidia-driver-550
    sudo apt install nvidia-dkms-550

    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
    sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
  2. Ahanio revised this gist Jul 3, 2024. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions cuda 12.1
    Original file line number Diff line number Diff line change
    @@ -17,12 +17,12 @@ sudo rm /etc/apt/sources.list.d/cuda*
    sudo apt-get autoremove && sudo apt-get autoclean
    sudo rm -rf /usr/local/cuda*

    ### Make GCC-11 as the default GCC version.
    ### Make GCC-10 as the default GCC version.
    sudo apt update -y
    sudo apt upgrade -y
    sudo apt install -y build-essential
    sudo apt install -y gcc-11 g++-11 cpp-11
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
    sudo apt install -y gcc-10 g++-10 cpp-10
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10

    # system update
    sudo apt-get update
  3. Ahanio created this gist Jul 3, 2024.
    67 changes: 67 additions & 0 deletions cuda 12.1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    #!/bin/bash

    ### steps ####
    # verify the system has a cuda-capable gpu
    # download and install the nvidia cuda toolkit and cudnn
    # setup environmental variables
    # verify the installation
    ###

    ### to verify your gpu is cuda enable check
    lspci | grep -i nvidia

    ### If you have previous installation remove it first.
    sudo apt-get purge nvidia*
    sudo apt remove nvidia-*
    sudo rm /etc/apt/sources.list.d/cuda*
    sudo apt-get autoremove && sudo apt-get autoclean
    sudo rm -rf /usr/local/cuda*

    ### Make GCC-11 as the default GCC version.
    sudo apt update -y
    sudo apt upgrade -y
    sudo apt install -y build-essential
    sudo apt install -y gcc-11 g++-11 cpp-11
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11

    # system update
    sudo apt-get update
    sudo apt-get upgrade

    # install other import packages
    sudo apt-get install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev

    # first get the PPA repository driver
    sudo add-apt-repository ppa:graphics-drivers/ppa
    sudo apt update

    # install nvidia driver with dependencies
    sudo apt install libnvidia-common-535
    sudo apt install libnvidia-gl-535
    sudo apt install nvidia-driver-535
    sudo apt install nvidia-dkms-535

    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
    sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
    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-get update

    # installing CUDA-12.1
    sudo apt install cuda-12-1

    # Download cuDNN 8.9.4 tar from NVIDIA Official site: https://developer.nvidia.com/rdp/cudnn-archive
    CUDNN_TAR_FILE='cudnn-linux-x86_64-8.9.4.25_cuda12-archive'
    tar -xf Downloads/${CUDNN_TAR_FILE}.tar.xz

    # copy the following files into the cuda toolkit directory.
    sudo cp -P ${CUDNN_TAR_FILE}/include/cudnn.h /usr/local/cuda-12.1/include
    sudo cp -P ${CUDNN_TAR_FILE}/lib/libcudnn* /usr/local/cuda-12.1/lib64/
    sudo chmod a+r /usr/local/cuda-12.1/lib64/libcudnn*

    # adding NVCC to environment path
    export PATH=$PATH:/usr/local/cuda-12.1/bin

    # Finally, to verify the installation, reboot and check
    nvidia-smi
    nvcc -V