How did I install CUDA 10.0 and the latest NVIDIA driver to Ubuntu 18.04?

Step 1

apt-get install build-essential dkms freeglut3 freeglut3-dev libxi-dev libxmu-dev

Step 2

I went to the CUDA websiite for installation instructions.

developer.nvidia.com/cuda-10.0-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=debnetwork

02

Step 3

I have got the installer URL via the «Download» button:
04

Step 4

I have downloaded the installer:

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.deb

Step 5

dpkg -i cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
apt-get update
apt install cuda-toolkit-10-0

Step 6

reboot

Step 7

Then I checked that the Nvidia's driver is installed:

lspci -k | grep -A 2 -i "VGA"

05

Step 8

Then I checked the installed CUDA version.
It was 10.1 in my case:

06

Tensorflow 1.13 is not compatible with CUDA 10.1, so I downgraded CUDA from 10.1 to 10.0

Step 9

Then I checked the installed Nvidia driver version:

nvidia-smi

02

Step 10

I have added to /root/.bash_profile:

export CUDADIR=/usr/local/cuda-10.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.0/lib64
export PATH=$PATH:/usr/local/cuda-10.0/bin

Step 11

Then I reloaded /root/.bash_profile:

source ~/.bash_profile

stackoverflow.com/a/4608197

Step 12

Then I cheched the environment variables:

echo "$CUDADIR"
echo "$LD_LIBRARY_PATH"
echo "$PATH"

01

Step 13

cuda-install-samples-10.0.sh ~

02

Step 14

cd ~/NVIDIA_CUDA-10.0_Samples/5_Simulations/nbody
make