Skip to content

Latest commit

 

History

History
131 lines (107 loc) · 4.61 KB

File metadata and controls

131 lines (107 loc) · 4.61 KB

Install-Tensorflow-GPU-2.1.0-on-Linux-Ubuntu-18.04

Easily Install Tensorflow-GPU 2.0 on Linux Ubuntu 18.04 -Cuda 10 & Cudnn 7.6.5

Requirements:

An NVIDIA GPU with a compute capability of 3.0 or higher
Python installed (Install Python 3.4+)

option1: Install Python 3 From Source Code. ---> Link.

option2: Install Python 3 Using apt (Easier)

sudo add-apt-repository ppa:jonathonf/python-3.7
sudo apt-get update
sudo apt-get install python3.7

Install Pip3
sudo apt install python3-pip

Install Python and the TensorFlow package dependencies

(https://www.tensorflow.org/install/source) ✔️

install pakage

Tested build configurationsDownload Build Tools: Download Bazel 0.26.1.

Download Compiler GCC 7.3.1: GCC 7.3.1.

Overview

Step 1: Update your GPU driver (should be higher than version 390)
Step 2: Install the CUDA Toolkit version 10.0
Step 3: Install CUDNN 7.6.5
Step 4: Install Tensorflow GPU 2.0v with pip
Step 5: Test Run GPU

Step 1: Update your GPU driver

Open a terminal and run the following 3 commands

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-390 or higher version
sudo apt install nvidia-cuda-toolkit

Reboot your computer. To verify the installation, open a terminal and run the following command

nvidia-smi The output should show the GPU name and the driver.show the GPU name and the driver

Step 2: Install the CUDA Toolkit (10.0)

CUDA Toolkit Archive " https://developer.nvidia.com/cuda-toolkit-archive" go to https://developer.nvidia.com/cuda-10.0-download-archive and download the toolkit for Linux, x86_64, ubuntu, 18.04, deb(local) once the download is complete, open a terminal in the directory the base installer is and run the following commands

sudo dpkg -i cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

download patch 1 and install (you should get a prompt to install once its done downloading)
download patch 2 and install (you should get a prompt to install once its done downloading)

open your .bashrc file with nano

sudo nano ~/.bashrc

go to the last line and add the following lines (this will set your PATH variable)

export PATH=/usr/local/cuda-10.0/bin${PATH:+:$PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda 10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Step 3: Install CUDNN 7.6.5

go to https://developer.nvidia.com/cudnn
Select CUDNN 7.6.5 for CUDA 10.0
download the cuDNN v7.6.5 Library for Linux (Download with Link.)
open a terminal in the directory the tar file is located
unzip the tar file using the command

tar -xzvf cudnn-10.0-linux-x64-v7.6.5.32.tgz

run the following commands to move the appropriate files to the CUDA folder

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*

Step 4: pip install TensorFlow-GPU 2.0

I will be using a conda environment for installing TensorFlow
create a conda environment by using the following command

conda create -n tf python=3.7 pip

activate your environment using

source activate tf

create an environment without conda

sudo pip3 install virtualenv

virtualenv venv (you can use any name insted of venv)
source venv/bin/activate (Active your virtual environment)

install TensorFlow-GPU 2.0 with pip3

sudo pip3 install tensorflow-gpu==2.0.0

Step 5: Test it!

import tensorflow as tf
tf.test.is_gpu_available(
    cuda_only=False,
    min_cuda_compute_capability=None
)

if the output was True then everything OK!
tensorflow gpu

References:
https://medium.com/@m_farzalizadeh/easily-install-tensorflow-gpu-2-0-on-linux-ubuntu-18-04-cuda-10-cudnn-7-6-5-1ecb354e68bc