项目作者: miladfa7

项目描述 :
Easily Install Tensorflow-GPU 2.1.0 on Linux Ubuntu 18.04 -Cuda 10 & Cudnn 7.6.5 | Download package dependencies with direct link
高级语言:
项目地址: git://github.com/miladfa7/Install-Tensorflow-GPU-2.1.0-on-Linux-Ubuntu-18.04.git


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)

  1. sudo add-apt-repository ppa:jonathonf/python-3.7
  2. sudo apt-get update
  3. 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

  1. sudo add-apt-repository ppa:graphics-drivers/ppa
  2. sudo apt update
  3. sudo apt install nvidia-390 or higher version
  4. sudo apt install nvidia-cuda-toolkit

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

  1. The output should show the GPU name and the driver.show the GPU name and the driver
  2. ### Step 2: Install the CUDA Toolkit (10.0) <br>
  3. CUDA Toolkit Archive " https://developer.nvidia.com/cuda-toolkit-archive"
  4. go to https://developer.nvidia.com/cuda-10.0-download-archive and download the toolkit for Linux, x86_64, ubuntu, 18.04, deb(local)
  5. once the download is complete, open a terminal in the directory the base installer is and run the following commands
  6. <br>

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-/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

  1. download patch 1 and install (you should get a prompt to install once its done downloading)<br>
  2. download patch 2 and install (you should get a prompt to install once its done downloading)<br>
  3. open your .bashrc file with nano<br>
  4. ``` sudo nano ~/.bashrc

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

  1. export PATH=/usr/local/cuda-10.0/bin${PATH:+:$PATH}}
  2. 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

  1. 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

  1. sudo cp cuda/include/cudnn.h /usr/local/cuda/include
  2. sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
  3. 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

  1. conda create -n tf python=3.7 pip

activate your environment using

  1. source activate tf

create an environment without conda

  1. sudo pip3 install virtualenv
  2. virtualenv venv (you can use any name insted of venv)
  3. source venv/bin/activate (Active your virtual environment)

install TensorFlow-GPU 2.0 with pip3

  1. sudo pip3 install tensorflow-gpu==2.0.0

Step 5: Test it!

  1. import tensorflow as tf
  2. tf.test.is_gpu_available(
  3. cuda_only=False,
  4. min_cuda_compute_capability=None
  5. )

if the output was True then everything OK!

tensorflow gpu

References:

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