NVIDIA Optimized Frameworks
NVIDIA Optimized Frameworks (Latest Release) Download PDF

Installing TensorFlow for Jetson Platform

Abstract

This guide provides instructions for installing TensorFlow for Jetson Platform.


TensorFlow on Jetson Platform

TensorFlow™ is an open-source software library for numerical computation using data flow graphs. Nodes in the graph represent mathematical operations, while the graph edges represent the multidimensional data arrays (tensors) that flow between them. This flexible architecture lets you deploy computation to one or more CPUs or GPUs in a desktop, server, or mobile device without rewriting code.

Jetson AGX Orin

Bring your next-gen products to life with the world's most powerful AI computer for energy-efficient autonomous machines. With up to 275 TOPS for running the NVIDIA AI software stack, this developer kit lets you create advanced robotics and edge AI applications for manufacturing, logistics, retail, service, agriculture, smart city, healthcare, and life sciences.

Jetson Orin NX

The NVIDIA Jetson Orin NX brings supercomputer performance to the edge in a small form factor system-on-module. Up to 21 TOPS of accelerated computing delivers the horsepower to run modern neural networks in parallel and process data from multiple high-resolution sensors — a requirement for full AI systems.

Jetson AGX Xavier

The NVIDIA Jetson AGX Xavier developer kit for Jetson platform is the world's first AI computer for autonomous machines. The Jetson AGX Xavier delivers the performance of a GPU workstation in an embedded module under 30W.

1.1. Benefits of TensorFlow on Jetson Platform

Installing TensorFlow for Jetson Platform provides you with the access to the latest version of the framework on a lightweight, mobile platform without being restricted to TensorFlow Lite.


Before you install TensorFlow for Jetson, ensure you:

  1. Install JetPack on your Jetson device.
  2. Install system packages required by TensorFlow:
    Copy
    Copied!
                

    $ sudo apt-get update $ sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran

  3. Install and upgrade pip3.
    Copy
    Copied!
                

    $ sudo apt-get install python3-pip $ sudo python3 -m pip install --upgrade pip $ sudo pip3 install -U testresources setuptools==65.5.0

  4. Install the Python package dependencies.
    Copy
    Copied!
                

    $ sudo pip3 install -U numpy==1.22 future==0.18.2 mock==3.0.5 keras_preprocessing==1.1.2 keras_applications==1.0.8 gast==0.4.0 protobuf pybind11 cython pkgconfig packaging h5py==3.7.0


Note:

As of the 20.02 TensorFlow release, the package name has changed from tensorflow-gpu to tensorflow. See the section on Upgrading TensorFlow for more information.

Install TensorFlow using pip3. This command will install the latest version of TensorFlow compatible with JetPack 5.1.2.

Copy
Copied!
            

$ sudo pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v512 tensorflow==2.12.0+nv23.06


If you want to install an older version of TensorFlow, issue the following command:

Copy
Copied!
            

$ sudo pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v$JP_VERSION tensorflow==$TF_VERSION+nv$NV_VERSION

Where:

JP_VERSION
The major and minor version of JetPack you are using, such as 42 for JetPack 4.2.2 or 33 for JetPack 3.3.1.
Note:

For JetPack versions 5.0.2 and 4.6.1, JP_VERSION includes the patch version, and would therefore be 502 and 461, instead of 50 and 46, respectively.

TF_VERSION
The released version of TensorFlow, for example, 2.11.0 or 1.15.5.
NV_VERSION
The monthly NVIDIA container version of TensorFlow, for example, 23.01.
Note:

The version of TensorFlow you are trying to install must be supported by the version of JetPack you are using. Also, the package name may be different for older releases. See the TensorFlow For Jetson Platform Release Notes for a list of some recent TensorFlow releases with their corresponding package names, as well as NVIDIA container and JetPack compatibility.


For example, to install TensorFlow 2.9.1 as of the 22.09 release, use the following command:

Copy
Copied!
            

$ sudo pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v502 tensorflow-gpu==2.9.1+nv22.09

3.1. Installing Multiple TensorFlow Versions

If you want to have multiple versions of TensorFlow available at the same time, this can be accomplished using virtual environments. See below.

Set up the Virtual Environment

First, install thevirtualenv package and create a new Python 3 virtual environment:

Copy
Copied!
            

$ sudo apt-get install virtualenv $ python3 -m virtualenv -p python3 <chosen_venv_name>


Activate the Virtual Environment

Next, activate the virtual environment:

Copy
Copied!
            

$ source <chosen_venv_name>/bin/activate

Install the desired version of TensorFlow and its dependencies:

Copy
Copied!
            

$ pip3 install -U numpy grpcio absl-py py-cpuinfo psutil portpicker six mock requests gast h5py astor termcolor protobuf keras-applications keras-preprocessing wrapt google-pasta setuptools testresources $ pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v51 tensorflow==$TF_VERSION+nv$NV_VERSION


Deactivate the Virtual Environment

Finally, deactivate the virtual environment:

Copy
Copied!
            

$ deactivate


Run a Specific Version of TensorFlow

After the virtual environment has been set up, simply activate it to have access to the specific version of TensorFlow. Make sure to deactivate the environment after use:

Copy
Copied!
            

$ source <chosen_venv_name>/bin/activate $ <Run the desired TensorFlow scripts> $ deactivate

3.2. Upgrading TensorFlow

To upgrade to a more recent release of TensorFlow, if one is available, run the install command with the ‘upgrade’ flag:

Copy
Copied!
            

$ sudo pip3 install --upgrade --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v51 tensorflow==2.11.0+nv23.01


About this task

To verify that TensorFlow has been successfully installed on your device, you’ll need to launch a Python prompt and import TensorFlow.

Procedure

  1. From the terminal, run:
    Copy
    Copied!
                

    $ python3

  2. Import TensorFlow:
    Copy
    Copied!
                

    >>> import tensorflow

    If TensorFlow was installed correctly, this command should execute without error.


Performance model

It is recommended to choose the right performance mode to get the best possible performance given energy usage limitations. There is a command line tool (nvpmodel) that can be used to change the performance mode. In order to check the current performance mode, issue:

Copy
Copied!
            

$ sudo nvpmodel -q --verbose


To change the mode to MAX-N, issue:

Copy
Copied!
            

$ sudo nvpmodel -m 0


For more information, see:

Swap space on Jetson Xavier

On Jetson Xavier, certain applications could run out of memory (16GB shared between CPU and GPU). This problem can be resolved by creating a swap partition on the external memory. Typically 4GB of swap space is enough.


TensorFlow can easily be uninstalled using the pip3 uninstall command, as below:

Copy
Copied!
            

$ sudo pip3 uninstall -y tensorflow


Note:

If you are If you are using a version of TensorFlow older than the 20.02 release, the package name is tensorflow-gpu, and you will need to run the following command to uninstall TensorFlow instead. See the TensorFlow For Jetson Platform Release Notes for more information.

Copy
Copied!
            

$ sudo pip3 uninstall -y tensorflow-gpu



Join the NVIDIA Jetson and Embedded Systems community to discuss Jetson Platform-specific issues.

Notice

This document is provided for information purposes only and shall not be regarded as a warranty of a certain functionality, condition, or quality of a product. NVIDIA Corporation (“NVIDIA”) makes no representations or warranties, expressed or implied, as to the accuracy or completeness of the information contained in this document and assumes no responsibility for any errors contained herein. NVIDIA shall have no liability for the consequences or use of such information or for any infringement of patents or other rights of third parties that may result from its use. This document is not a commitment to develop, release, or deliver any Material (defined below), code, or functionality.

NVIDIA reserves the right to make corrections, modifications, enhancements, improvements, and any other changes to this document, at any time without notice.

Customer should obtain the latest relevant information before placing orders and should verify that such information is current and complete.

NVIDIA products are sold subject to the NVIDIA standard terms and conditions of sale supplied at the time of order acknowledgement, unless otherwise agreed in an individual sales agreement signed by authorized representatives of NVIDIA and customer (“Terms of Sale”). NVIDIA hereby expressly objects to applying any customer general terms and conditions with regards to the purchase of the NVIDIA product referenced in this document. No contractual obligations are formed either directly or indirectly by this document.

NVIDIA products are not designed, authorized, or warranted to be suitable for use in medical, military, aircraft, space, or life support equipment, nor in applications where failure or malfunction of the NVIDIA product can reasonably be expected to result in personal injury, death, or property or environmental damage. NVIDIA accepts no liability for inclusion and/or use of NVIDIA products in such equipment or applications and therefore such inclusion and/or use is at customer’s own risk.

NVIDIA makes no representation or warranty that products based on this document will be suitable for any specified use. Testing of all parameters of each product is not necessarily performed by NVIDIA. It is customer’s sole responsibility to evaluate and determine the applicability of any information contained in this document, ensure the product is suitable and fit for the application planned by customer, and perform the necessary testing for the application in order to avoid a default of the application or the product. Weaknesses in customer’s product designs may affect the quality and reliability of the NVIDIA product and may result in additional or different conditions and/or requirements beyond those contained in this document. NVIDIA accepts no liability related to any default, damage, costs, or problem which may be based on or attributable to: (i) the use of the NVIDIA product in any manner that is contrary to this document or (ii) customer product designs.

No license, either expressed or implied, is granted under any NVIDIA patent right, copyright, or other NVIDIA intellectual property right under this document. Information published by NVIDIA regarding third-party products or services does not constitute a license from NVIDIA to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property rights of the third party, or a license from NVIDIA under the patents or other intellectual property rights of NVIDIA.

Reproduction of information in this document is permissible only if approved in advance by NVIDIA in writing, reproduced without alteration and in full compliance with all applicable export laws and regulations, and accompanied by all associated conditions, limitations, and notices.

THIS DOCUMENT AND ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS, DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY, “MATERIALS”) ARE BEING PROVIDED “AS IS.” NVIDIA MAKES NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL NVIDIA BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF ANY USE OF THIS DOCUMENT, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Notwithstanding any damages that customer might incur for any reason whatsoever, NVIDIA’s aggregate and cumulative liability towards customer for the products described herein shall be limited in accordance with the Terms of Sale for the product.

HDMI

HDMI, the HDMI logo, and High-Definition Multimedia Interface are trademarks or registered trademarks of HDMI Licensing LLC.

OpenCL

OpenCL is a trademark of Apple Inc. used under license to the Khronos Group Inc.

Trademarks

NVIDIA, the NVIDIA logo, and cuBLAS, CUDA, DALI, DGX, DGX-1, DGX-2, DGX Station, DLProf, Jetson, Kepler, Maxwell, NCCL, Nsight Compute, Nsight Systems, NvCaffe, PerfWorks, Pascal, SDK Manager, Tegra, TensorRT, Triton Inference Server, Tesla, TF-TRT, and Volta are trademarks and/or registered trademarks of NVIDIA Corporation in the U.S. and other countries. Other company and product names may be trademarks of the respective companies with which they are associated.

© 2018-2024 NVIDIA Corporation & Affiliates. All rights reserved. Last updated on Sep 30, 2024.