在jetson nano中安装jetson.inference模块

jetson.inference 是 NVIDIA Jetson 平台的一部分,用于运行深度学习推理。确保你的开发环境是 NVIDIA Jetson 设备,然后按照官方文档进行安装:https://github.com/dusty-nv/jetson-inference

jetson-inference 不是通过 pip 安装的常规 Python 包。它是一个专为 NVIDIA Jetson 平台设计的库,需要通过特定的步骤进行编译和安装。你不能通过常规的 pip 命令来安装它。

为了在你的 NVIDIA Jetson 设备上安装 jetson-inference, 你应该按照以下步骤操作:
克隆仓库:
打开你的终端,然后使用以下命令克隆 jetson-inference GitHub 仓库:

git clone https://github.com/dusty-nv/jetson-inference

构建项目:
进入克隆的仓库目录,并设置构建文件:

cd jetson-inference
mkdir build
cd build
cmake ../

编译和安装:
使用以下命令来编译和安装库:

make
sudo make install
sudo ldconfig

配置和运行示例:
还可以运行下载模型和数据的脚本:

cd ../tools
./download-models.sh
./download-datasets.sh

然后你可以尝试运行一些示例来确保一切工作正常。

cd ../build/aarch64/bin
./imagenet-console orange_0.jpg output_0.jpg

确保遵循这些步骤,并根据需要调整命令。这些命令应该在你的 NVIDIA Jetson 设备上运行,因为 jetson-inference 库利用了 NVIDIA 的 GPU 和特定硬件优化。如果在安装过程中遇到任何问题,请参考官方文档或寻求社区支持。

如果出现下面错误

jetson@nano:~/yolo/jetson-inference/build$ cmake …/
– The C compiler identification is GNU 8.4.0
– The CXX compiler identification is GNU 8.4.0
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /usr/bin/c++
– Check for working CXX compiler: /usr/bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done

Note: this project uses git submodules in the source tree.
if you haven’t already, run the following command from
the project’s root directory:

       git submodule update --init
        Note:  required git submodules have not been detected.
   first, please run the following command from the
   the project's root directory to clone them:

      git submodule update --init

CMake Error at CMakeLists.txt:21 (message): missing required git
submodules, see instructions above

– Configuring incomplete, errors occurred! See also “/home/jetson/yolo/jetson-inference/build/CMakeFiles/CMakeOutput.log”.

根据错误信息,问题在于 git 子模块没有被正确初始化和更新。这是一个常见的问题,当你克隆一个使用子模块的 git 仓库但没有初始化这些子模块时会发生。

为了解决这个问题,你需要运行以下命令来初始化并更新子模块:

cd ~/yolo/jetson-inference
git submodule update --init

这个命令会检查 .gitmodules 文件并克隆必要的子模块到你的本地仓库中。完成这一步之后,你可以再次尝试运行 cmake 命令:

cd build
cmake ../

然后继续之前的编译和安装步骤:

make
sudo make install
sudo ldconfig

确保你在整个过程中位于正确的目录中,并且遵循所有步骤。这应该能解决子模块缺失的问题,并允许你继续安装 jetson-inference 库。

  • 16
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Jetson Nano上使用TensorRT加速Yolov5的推理可以按照以下步骤进行: 1. 安装TensorRT和Yolov5:首先确保你已经在Jetson Nano上安装JetPack SDK,该包包含了TensorRT和CUDA等必要的组件。你可以从NVIDIA官方网站下载并安装JetPack SDK。然后,你可以从Yolov5的GitHub页面获取Yolov5的代码。 2. 将Yolov5模型转换为TensorRT引擎:在Yolov5代码的根目录下,有一个`yolov5s.yaml`文件,它定义了模型的结构和超参数。你可以使用`convert.py`脚本将模型转换为TensorRT引擎。具体命令如下: ``` python convert.py --weights yolov5s.pt --cfg yolov5s.yaml --output yolov5s.engine ``` 这将生成一个名为`yolov5s.engine`的TensorRT引擎文件。 3. 编写推理代码:使用TensorRT引擎进行推理,可以使用Jetson Inference库。首先,确保你已经在Jetson Nano上安装Jetson Inference库。然后,创建一个新的Python文件,并添加以下代码: ```python import ctypes import numpy as np import cv2 import jetson.inference import jetson.utils ctypes.CDLL('libnvinfer_plugin.so', mode=ctypes.RTLD_GLOBAL) engine_path = 'yolov5s.engine' input_width = 640 input_height = 640 # 加载TensorRT引擎 trt_yolov5 = jetson.inference.detectNet(engine_path, threshold=0.5) # 加载输入图像 input_image = jetson.utils.loadImage('input.jpg') input_image = jetson.utils.cudaFromNumpy(input_image) # 设置网络的输入尺寸 trt_yolov5.SetInputWidth(input_width) trt_yolov5.SetInputHeight(input_height) # 进行目标检测 detections = trt_yolov5.Detect(input_image, input_width, input_height) # 处理检测结果 for detection in detections: class_name = trt_yolov5.GetClassDesc(detection.ClassID) print(f'Object: {class_name}, Confidence: {detection.Confidence:.2f}') left = int(detection.Left) top = int(detection.Top)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值