Install Tensorflow 2.0 with GPU Support and Jupyter Notebook

Let’s begin.
Step 1: Add NVIDIA package repositories
# create temp folder
mkdir ~/tmp && cd ~/tmpwget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.debsudo dpkg -i cuda-repo-ubuntu1804_10.0.130-1_amd64.debsudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pubsudo apt-get updatewget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.debsudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.debsudo apt-get update
Step 2: Install the NVIDIA driver
sudo apt-get install --no-install-recommends nvidia-driver-418
After that, reboot the system and type the command below:
nvidia-smi
You should see GPUs on the system:

Step 3: Install development and runtime libraries
sudo apt-get install --no-install-recommends cuda-10-0 libcudnn7=7.6.2.24-1+cuda10.0 libcudnn7-dev=7.6.2.24-1+cuda10.0
Step 4 (Optional): Install TensorRT
TensorRT to improve latency and throughput for inference on some models.
sudo apt-get install -y --no-install-recommends libnvinfer5=5.1.5-1+cuda10.0 libnvinfer-dev=5.1.5-1+cuda10.0
Step 5 : Install Anaconda
cd ~/tmpwget https://repo.anaconda.com/archive/Anaconda3-2019.07-Linux-x86_64.shbash ./Anaconda3-2019.07-Linux-x86_64.sh# 1. Review the license agreement then type ENTER
# 2. For accept the license terms: type 'yes'
# 3. Choose installation location, default is '~/anaconda3'
# 4. For initialize Anaconda3, type 'yes'source ~/.bashrc
After the installation is complete, you can prevent automatically activating the base anaconda environment with the following command:
conda config --set auto_activate_base falsesource ~/.bashrc
Check python and pip location:
which python && which pip
This command should give ~/anaconda3/bin/python and ~/anaconda3/bin/pip locations.
Step 6: Install Jupyer Notebook with conda
conda install -c anaconda jupyter
Step 7 (Optional): Jupyter Notebook Access Remotely
By default, a notebook server runs locally at 127.0.0.1:8888 and is accessible only from localhost. You may access the notebook server from the browser using http://127.0.0.1:8888.
If you are working on a cloud platform (GCloud, AWS, etc.), you may want to access jupyter notebook remotely. The next step shows you how to configure jupyter notebook for accessing remotely.
7.1: Generate config file
The following command will generate the configuration file at ~/.jupyter/jupyter_notebook_config.py.
jupyter notebook --generate-config
7.2: Generate SSL Certificate and Key File
A self-signed certificate can be generated with openssl
for encrypted communication.
mkdir ~/sslopenssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ~/ssl/key.key -out ~/ssl/cert.pem
7.3: Edit config file
Open the notebook config file (~/.jupyter/jupyter_notebook_config.py) with your favorite edit app like nano, vim and add this section top of the file:
c.NotebookApp.certfile = '/home/{USER}/ssl/cert.pem' # full path of cert.pem
c.NotebookApp.keyfile = '/home/{USER}/ssl/key.key' # full path of cert.pem
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
7.4: Setting Password
jupyter notebook password
Step 8: Install Tensorflow 2.0 with pip
pip install tensorflow-gpu==2.0.0

Final Checks:
After these steps finally, you can start jupyter notebook with the following command:
jupyter notebook
Then open a new jupyter notebook file, and write these three lines of code.
from __future__ import absolute_import, division, print_function, unicode_literalsimport tensorflow as tfprint("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

You should see the count of available GPUs on the system.

Cheers!
References: