Jetson nano 安装TensorFlow GPU

jupiter
2021-06-29 / 0 评论 / 679 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2021年12月07日,已超过1110天没有更新,若内容或图片失效,请留言反馈。

Jetson nano 安装TensorFlow GPU

1.Prerequisites and Dependencies

Before you install TensorFlow for Jetson, ensure you:

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

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

    $ sudo apt-get install python3-pip
    $ sudo pip3 install -U pip testresources setuptools==49.6.0 
  4. Install the Python package dependencies.

    $ sudo pip3 install -U numpy==1.19.4 future==0.18.2 mock==3.0.5 h5py==2.10.0 keras_preprocessing==1.1.1 keras_applications==1.0.8 gast==0.2.2 futures protobuf pybind11

2.Installing TensorFlow

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 the pip3 command. This command will install the latest version of TensorFlow compatible with JetPack 4.5.

$ sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v45 tensorflow

Note: TensorFlow version 2 was recently released and is not fully backward compatible with TensorFlow 1.x. If you would prefer to use a TensorFlow 1.x package, it can be installed by specifying the TensorFlow version to be less than 2, as in the following command:

$ sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v45 ‘tensorflow<2’

If you want to install the latest version of TensorFlow supported by a particular version of JetPack, issue the following command:

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

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.

If you want to install a specific version of TensorFlow, issue the following command:

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

  • TF_VERSION

    The released version of TensorFlow, for example, 1.13.1.

  • NV_VERSION

    The monthly NVIDIA container version of TensorFlow, for example, 19.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 1.13.1 as of the 19.03 release, the command would look similar to the following:

$ sudo pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu==1.13.1+nv19.3

Tensorflow-GPU测试是否可用

  1. Tensorflow-gpu 1.x.x, 如Tensorflow-gpu 1.2.0, 可使用以下代码
import tensorflow as tf
tf.test.is_gpu_available()
  1. Tensoeflow-gpu 2.x.x,如Tensorflow-gpu 2.2.0, 可使用以下代码
import tensorflow as tf
tf.config.list_physical_devices('GPU')

参考资料

  1. Installing TensorFlow For Jetson Platform:https://docs.nvidia.com/deeplearning/frameworks/install-tf-jetson-platform/index.html
  2. Tensorflow-GPU测试是否可用:https://www.jianshu.com/p/8eb7e03a9163
0

评论 (0)

打卡
取消