NVIDIA has created this project to support newer hardware and improved libraries to NVIDIA GPU users who are using TensorFlow 1.x. With release of TensorFlow 2.0, Google announced that new major releases will not be provided on the TF 1.x branch after the release of TF 1.15 on October 14 2019. NVIDIA is working with Google and the community to improve TensorFlow 2.x by adding support for new hardware and libraries. However, a significant number of NVIDIA GPU users are still using TensorFlow 1.x in their software ecosystem. This release will maintain API compatibility with upstream TensorFlow 1.15 release. This project will be henceforth referred to as nvidia-tensorflow.
Link to Tensorflow README
- Ubuntu 20.04 or later (64-bit)
- GPU support requires a CUDA®-enabled card
- For NVIDIA GPUs, the r455 driver must be installed
For wheel installation:
- Python 3.8
- pip 19.0 or later
NVIDIA wheels are not hosted on PyPI.org. To install the NVIDIA wheels for Tensorflow, install the NVIDIA wheel index:
$ pip install --user nvidia-pyindex
To install the current NVIDIA Tensorflow release:
$ pip install --user nvidia-tensorflow[horovod]
nvidia-tensorflow package includes CPU and GPU support for Linux.
Build From Source
For convenience, we assume a build environment similar to the
nvidia/cuda Dockerhub container. As of writing, the latest container is
nvidia/cuda:11.4.2-cudnn8-devel-ubuntu20.04. Users working within other environments will need to make sure they install the CUDA toolkit and CUDNN and NCCL libraries separately.
Fetch sources and install build dependencies.
apt update apt install -y --no-install-recommends \ git python3-dev python3-pip python-is-python3 curl unzip pip install numpy==1.17.3 wheel astor==0.8.1 pip install --no-deps keras_preprocessing==1.0.5 git clone https://github.com/NVIDIA/tensorflow.git -b r1.15.5+nv21.11 git clone https://github.com/NVIDIA/cudnn-frontend.git -b v0.5 BAZEL_VERSION=$(cat tensorflow/.bazelversion) mkdir bazel cd bazel curl -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh bash ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh cd - rm -rf bazel
We install TensorRT using the NVIDIA CUDA Network Repo for Debian, which is preconfigured in
nvidia/cuda Dockerhub images. Users working with their own build environment may find it useful to review the full TensorRT installation docs.
apt install -y --no-install-recommends \ libnvinfer8=8.0.3-1+cuda11.3 \ libnvinfer-plugin8=8.0.3-1+cuda11.3 \ libnvinfer-dev=8.0.3-1+cuda11.3 \ libnvinfer-plugin-dev=8.0.3-1+cuda11.3
The options below should be adjusted to match your build and deployment environments. In particular,
TF_CUDA_COMPUTE_CAPABILITIES may need to be chosen to ensure TensorFlow is built with support for all intended deployment hardware.
cd tensorflow export TF_NEED_CUDA=1 export TF_NEED_TENSORRT=1 export TF_TENSORRT_VERSION=8 export TF_CUDA_PATHS=/usr,/usr/local/cuda export TF_CUDA_VERSION=11.4 export TF_CUBLAS_VERSION=11 export TF_CUDNN_VERSION=8 export TF_NCCL_VERSION=2 export TF_CUDA_COMPUTE_CAPABILITIES="7.0,8.0" export TF_ENABLE_XLA=1 export TF_NEED_HDFS=0 export CC_OPT_FLAGS="-march=native -mtune=native" yes "" | ./configure
Build and install TensorFlow
bazel build -c opt --config=cuda --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0 tensorflow/tools/pip_package:build_pip_package bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/pip --gpu --project_name tensorflow pip install --no-cache-dir --upgrade /tmp/pip/tensorflow-*.whl
By using the software you agree to fully comply with the terms and conditions of the SLA (Software License Agreement):
If you do not agree to the terms and conditions of the SLA, do not install or use the software.
Please review the Contribution Guidelines.