< >
Home » TX2入门教程软件篇 » TX2入门教程软件篇-安装TensorFlow(jetpack4.2)

TX2入门教程软件篇-安装TensorFlow(jetpack4.2)

TX2入门教程软件篇-安装TensorFlow(jetpack4.2)

说明:

  • 介绍如何在jetpack4.2版本下tensorflow-gpu==2.0.0+nv19.11

安装依赖

  • 安装系统依赖
# install prerequisites
$ sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran cython3 

# install and upgrade pip3
$ sudo apt-get install python3-pip
$ sudo pip3 install -U pip testresources setuptools==49.6.0

系统环境安装:

  • 在系统环境安装
# install the following python packages
$ sudo pip3 install -U pkgconfig numpy==1.16.1 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==3.19.4 pybind11


# install the latest version of TensorFlow
$ sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu==2.0.0+nv19.11
  • 有时候可能会应为+号问题,自动下载回到的whell文件名变化,也可以采用wget直接下载whl文件,在安装
$ wget https://developer.download.nvidia.com/compute/redist/jp/v42/tensorflow-gpu/tensorflow_gpu-2.0.0+nv19.11-cp36-cp36m-linux_aarch64.whl

$ sudo pip3 install tensorflow_gpu-2.0.0+nv19.11-cp36-cp36m-linux_aarch64.whl
  • 可以查看https://developer.download.nvidia.com/compute/redist/jp/v42/tensorflow-gpu/下相应的版本

在虚拟环境安装

  • 安装虚拟环境
$ sudo apt-get install virtualenv
$ python3 -m virtualenv -p python3 venv
  • 进入虚拟环境
$ source venv/bin/activate
  • 安装Python依赖包
$ sudo pip3 install -U pkgconfig numpy==1.16.1 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==3.19.4 pybind11


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

#或者执行,安装最新版本
$  sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu
  • 退出虚拟环境
$ deactivate
  • 正常安装完之后,即可安装完成

测试:

  • 执行命令
sudo python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

参考:

  • https://elinux.org/Jetson_Zoo
  • Website: https://tensorflow.org
  • Source: https://github.com/tensorflow/tensorflow
  • https://docs.nvidia.com/deeplearning/frameworks/install-tf-jetson-platform/index.html

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: tx2入门教程软件篇