How to Build TensorFlow with GPU Support

From RidgeRun Developer Connection
Jump to: navigation, search


The following is an excerpt of the official TensorFlow installation instructions.

TensorFlow Configuration

All the steps below require these configuration steps. Make sure you run them prior.

TensorFlow Dependencies

sudo apt install git wget unzip python3 curl build-essential zlib1g-dev python3-numpy python3-six

# Some TF tools assume python is pointing to python3
# This uses the update-alternative util to do so. Caution,
# verify you don't have an alternative already configured
# by running "update-alternatives --config python"
#
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1

Configuration Variables

TF_VERSION=v2.0.1

TensorFlow Configuration Steps

git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow

# Move to a stable version
git checkout $TF_VERSION

# Important - download a valid bazel version
BAZEL=`awk -F"'" '/_TF_MAX_BAZEL_VERSION = /{print $2}' configure.py`
mkdir bazel
cd bazel
wget -c https://github.com/bazelbuild/bazel/releases/download/${BAZEL}/bazel-${BAZEL}-installer-linux-x86_64.sh
chmod +x bazel-${BAZEL}-installer-linux-x86_64.sh
sudo ./bazel-${BAZEL}-installer-linux-x86_64.sh
cd ..

# Configure tensorflow - I usually accept all defaults
# When asked for CUDA support say YES.
# When asked for TensorRT support say YES.
# Usually the script will find your installation if not, make sure they are properly installed
./configure

Building Components

Python Package

Make sure you run the configuration steps above first.

Python Dependencies

Python development packages and package manager

sudo apt install python3-dev python3-pip

Required python packages

sudo -H pip install pip six numpy wheel setuptools mock 'future>=0.17.1'
sudo -H pip install keras_applications --no-deps
sudo -H pip install keras_preprocessing --no-deps

TensorFlow Building

TensorFlow 2.x
bazel build //tensorflow/tools/pip_package:build_pip_package
TensorFlow 1.x

To make the TensorFlow package builder with GPU support:

bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

Building the TensorFlow wheel (.whl) package

# Set to your desired output location
OUTPUT_DIR=/tmp/tensorflow_pkg/

./bazel-bin/tensorflow/tools/pip_package/build_pip_package $OUTPUT_DIR


RidgeRun Resources

Quick Start Client Engagement Process RidgeRun Blog Homepage
Technical and Sales Support RidgeRun Online Store RidgeRun Videos Contact Us

OOjs UI icon message-progressive.svg Contact Us

Visit our Main Website for the RidgeRun Products and Online Store. RidgeRun Engineering informations are available in RidgeRun Professional Services, RidgeRun Subscription Model and Client Engagement Process wiki pages. Please email to support@ridgerun.com for technical questions and contactus@ridgerun.com for other queries. Contact details for sponsoring the RidgeRun GStreamer projects are available in Sponsor Projects page. Ridgerun-logo.svg
RR Contact Us.png