Skip to content

Instantly share code, notes, and snippets.

@ksopyla
Last active August 10, 2023 08:05
Show Gist options
  • Save ksopyla/828012d8d6fa2493dde68179e5d7c85c to your computer and use it in GitHub Desktop.
Save ksopyla/828012d8d6fa2493dde68179e5d7c85c to your computer and use it in GitHub Desktop.
NVidia Cuda installation for Ubuntu 18.04. Tested with CUDA 10.1, 10.2, 11.1
#!/bin/bash
## This gist contains step by step instructions to install cuda v10.0 and cudnn 7.5 in Ubuntu 18.04
## Clean install
### 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*
### to verify your gpu is cuda enable check
lspci | grep -i nvidia
### gcc compiler is required for development using the cuda toolkit. to verify the version of gcc install enter
gcc --version
# 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
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda
# copy CUDNN lib to cuda path, first download CUDNN from NVidia
tar -xzvf cudnn-11.0-linux-x64-v8.0.2.39.tgz
sudo cp cuda/include/cudnn*.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
@adagolodjo
Copy link

The last line is correct ? I think it should be "sudo apt-get -y install cuda"

@ksopyla
Copy link
Author

ksopyla commented Oct 20, 2020

yes you are right

@MotorCityCobra
Copy link

I went through the exact steps and it install CUDA 11-1

@ksopyla
Copy link
Author

ksopyla commented Nov 9, 2020

I went through the exact steps and it install CUDA 11-1

@MotorCityCobra good to hear it was helpful 👍

@gururajdori
Copy link

Failed to initialize NVML: Driver/library version mismatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment