Jetson Nano是英伟达公司推出的一款功能强大的AI入门学习开发板,配备了128核的Maxwell GPU, 4核Arm Cotex A57 CPU,4G内存,支持摄像头,usb,HDMI接口,sd卡扩展,还提供了GPIO, I2C, I2S, SPI, UART通用的单片机接口。由于其强大的硬件配置,AI模型可以直接在本地训练和推导。
一、拷贝Jetson-inference 源到本地目录:
1.更新Linux系统的安装包,安装git和cmake工具
$ sudo apt-get update$ sudo apt-get install git cmake
2. 拷贝jetson-inference源到本地
$ git clone --recursive https://github.com/dusty-nv/jetson-inference
或者
$ git clone https://github.com/dusty-nv/jetson-inference$ cd jetson-inference$ git submodule update --init
以拷贝jetson-inference所有子目录。
二、安装相关Python开发包
该项目的 Python 功能是通过 Python 扩展模块实现的,这些模块使用 Python C API 提供与本机 C++ 代码的绑定。在配置项目时,repo 会搜索在系统上安装了开发包的 Python 版本,然后将为存在的每个 Python 版本(例如 Python 2.7、3.6 和 3.7)构建绑定。它还将为已安装的 numpy 版本构建 numpy 绑定。
默认情况下,Ubuntu 预装了 libpython-dev 和 python-numpy 包(适用于 Python 2.7)。虽然 Ubuntu 预装了 Python 3.6 解释器,但 Python 3.6 开发包 (libpython3-dev) 和 python3-numpy 没有。使用 Python C API 构建绑定需要这些开发包。
因此,如果您希望项目为 Python 3.6 创建绑定,请在继续之前安装这些包:
$ sudo apt-get install libpython3-dev python3-numpy
除了 Python 2.7(已经预装)之外,安装这些附加包将使源为 Python 3.6 构建扩展绑定。然后在构建过程之后,jetson.inference 和 jetson.utils 包将可以在您的 Python 环境中使用。
三、配置CMake
接下来,在项目中创建一个构建目录并运行 cmake 来配置构建。运行 cmake 时,会启动一个脚本 (CMakePreBuild.sh),它将安装任何所需的依赖项并为您下载 DNN 模型。
$ cd jetson-inference # omit if working directory is already jetson-inference/ from above
$ mkdir build
$ cd build
$ cmake ../
注意:此命令将启动 CMakePreBuild.sh 脚本,该脚本在 Jetson 上安装一些必备软件包时要求 sudo 权限。该脚本还从 Web 服务下载预训练的网络。
四、下载模型
该项目带有许多预训练的网络,您可以选择通过模型下载工具 (download-models.sh) 下载和安装这些网络。默认情况下,并非所有模型最初都选择下载以节省磁盘空间。您可以选择所需的模型,或者稍后再次运行该工具以再次下载更多模型。
在初始配置项目时,cmake 会自动为您运行模型下载工具:

要稍后再次运行 Model Downloader 工具,您可以使用以下命令:
$ cd jetson-inference/build
$ ./download-models.sh
五、安装Pytorch
如果您使用的是 JetPack 4.2 或更高版本,如果您想在教程后面使用迁移学习重新训练网络,现在将运行另一个工具,可以选择在您的 Jetson 上安装 PyTorch。这一步是可选的,如果你不想做迁移学习的步骤,你不需要安装 PyTorch,可以跳过这一步。
如果需要,请选择您要安装的 Python 2.7 和/或 Python 3.6 的 PyTorch 包版本,然后按 Enter 继续。否则,不要选择这些选项,它将跳过 PyTorch 的安装。

六、编译项目
确保您仍然在上面步骤 3 中创建的 jetson-inference/build 目录中。
然后运行 make 和 sudo make install 来构建库、Python 扩展绑定和代码示例:
$ cd jetson-inference/build # omit if working directory is already build/ from above
$ make
$ sudo make install
$ sudo ldconfig
项目将构建到 jetson-inference/build/aarch64,目录结构如下:
|-build
\aarch64
\bin where the sample binaries are built to
\networks where the network models are stored
\images where the test images are stored
\include where the headers reside
\lib where the libraries are build to
在构建树中,您可以在 build/aarch64/bin/ 中找到二进制文件,在 build/aarch64/include/ 中找到头文件,在 build/aarch64/lib/ 中找到库。这些也会在 sudo make install 步骤中安装在 /usr/local/ 下。
jetson.inference 和 jetson.utils 模块的 Python 绑定也会在 /usr/lib/python*/dist-packages/ 下的 sudo make install 步骤中安装。如果您更新代码,请记住再次运行它。