Skip to main content
Version: 2.0

Ubuntu GPU Setup

Detailed here are the steps taken for Ubuntu GPU setup to uninstall/(re)install NVIDIA/CUDA. Note that the NVIDIA driver and CUDA keyring are dependent on the user's own GPU hardware and Ubuntu version. Steps may differ slightly dependent on these factors and are noted.

  1. Removal of previous installs of NVIDIA/CUDA (not required if you've never installed):

    sudo apt install --reinstall linux-image-generic
    sudo apt install --reinstall linux-headers-generic

    sudo apt remove --purge '^nvidia-.*'
    sudo apt remove --purge '^libnvidia-.*'

    sudo apt-get --purge remove "*cuda*" "*cublas*" "*cufft*" "*cufile*" "*curand*" "*cusolver*" "*cusparse*" "*gds-tools*" "*npp*" "*nvjpeg*" "nsight*" "*nvvm*"
    sudo apt-get --purge remove "*nvidia*" "libxnvctrl*"

    sudo apt-get autoremove
  2. Install NVIDIA driver 525 (This may be different between setups. Users will need to figure out what NVIDIA driver they need based on their GPU hardware and Linux software.)

      sudo apt-get install nvidia-driver-525
  3. Restart computer and try running nvidia-smi to see if NVIDIA side is correctly setup. The next step is installing CUDA.

  4. Get CUDA keyring (this version (Ubuntu 18.04) works for the specific ubuntu version 22.04, again users may need to find their specific CUDA keyring needed)

    sudo dpkg -i cuda-keyring_1.0-1_all.deb
  5. Install CUDA drivers (get these from the keyring)

      sudo apt-get update
    sudo apt-get install cuda-drivers-525
    sudo apt-get install cuda-toolkit-11-2
  6. Added CUDA to path in .profile and in /etc/environment file

    export PATH=/usr/local/cuda-11.2/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  7. Install python-3 dev package:

      sudo apt-get install python3.7-dev
  8. Install NumPy/pyCUDA:

      python3 -m pip install numpy
    python3 -m pip install 'pycuda<2021.1'
  9. Install cuDNN / NVIDIA optimization (again system specific, this works on Ubuntu 22.04):

    sudo mv /etc/apt/preferences.d/cuda-repository-pin-600
    sudo apt-key adv --fetch-keys
    sudo add-apt-repository "deb /"
    sudo apt-get update
    (for CUDA 11.2)
    sudo apt-get install libcudnn8=8.1.0.*-1+cuda11.2
    sudo apt-get install libcudnn8-dev=8.1.0.*-1+cuda11.2
  10. Install NVIDIA-Docker2:

      sudo apt-get update
    sudo apt-get install -y nvidia-docker2
    sudo systemctl restart docker
  11. Restart Computer! Confirm that everything works through individual commands (NVIDIA: nvidia-smi and CUDA: nvcc -v) or use the ./bin/graphgrid gpu check command to check if you system is now GraphGrid GPU compatible.