英伟达nx-1

BSP开发指导:
https://docs.nvidia.com/jetson/l4t/index.html
Jetpack release
https://developer.nvidia.com/embedded/linux-tegra-r3261

nvidia docker:
https://catalog.ngc.nvidia.com
https://github.com/NVIDIA/nvidia-docker
https://hub.docker.com/r/nvidia/cuda-arm64/tags

sdkmanager:
https://developer.nvidia.com/nvidia-sdk-manager-archive

1-本文基本介绍nx 系列功能,关注nx

Jetson是NVIDIA嵌入式计算平台的总称,定位是面向各类端用户的应用需求,根据大家算力、产品设计、外接传感器等需求,打造了不用技术规格的嵌入式计算平台,为各行业提供了低功耗高性能的AI解决方案。现在市面上的Jetson产品有以下四款。尺寸、算力以及功耗请参看图中详情,更详细的技术参数信息请到NVIDIA官网上查看。


除了针对不同场景需求的硬件平台之外,Jetson系列还为用户提供了一系列的软件解决方案。比如Jetpack,大家可以把Jetpack理解为我们的系统镜像,里面包含了linux内核,我们开发依赖的库函数,比如CUDA、TensorRT等等以及RTOS实时操作系统。同时Jetpack还是一层软件隔离层,最大程度降低了嵌入式平台上软件的迁徙成本。Jetson的软件堆栈如下图所示


软件架构

除了Jetpack之外,Jetson还有视频图像检测分析的SDK DeepStream以及机器人解决方案ISAAC,其中DeepStream从视频取流/图像获取到检测结果的跟踪输出搭建了一整套pipeline,并且每个环节都和Jetson的硬件资源紧密结合,最大程度地优化了每个环节,帮助大家用最快的时间以最有效地方式实现算法的落地。DeepStream工作框图如下


如何安装 python3
sudo apt-get install python3-pip python3-dev
/usr/bin 下面有python 软链接,切换就是软链接指向不同的python version
python3 -m pip install --upgrade pip  #升级pip

查看系统jetpack 信息:
sudo -H pip3 install jetson-stats
jtop 查看英伟达板子信息
jetson_release

# nx 板子性能测试
#查询当前状态
sudo nvpmodel --q

#切换状态
sudo nvpmodel -m #Mode_ID

#查看处理器状态
sudo jetson_clocks --show

#如果jetson_clocks后没有参数,则直接开启static MAX模式
sudo jetson_clocks

sudo jetson_clocks --help //查看参数说明

sudo apt install lm-sensors  #安装温度检测工具
sensors  #显示Xavier  nx当前温度

#风扇如果有,那个可以控制,chmod 666 target_pwm
sudo sh -c "echo 100 > /sys/devices/pwm-fan/target_pwm"  #转速为100

通过界面查看nvpmodel 模式,sudo nvpmodel -m #Mode_ID切换模式
切换模式之后sudo jetson_clocks 让系统满负荷跑。

查看系统信息:

1、驱动版本:head -n 1 /etc/nv_tegra_release
2、内核版本:uname -r
3、操作系统:lsb_release -i -r
4、CUDA版本:nvcc -V
5、cuDNN版本:dpkg -l libcudnn8
6、opencv版本:dpkg -l libopencv
7、Tensorrt版本: dpkg -l tensorrt

烧录说明:

AGX:

系统镜像生成并升级(把机器中的所有内容擦除并刷机,重新制作system.img)
$sudo ./flash.sh jetson-xavier mmcblk0p1 

系统完整升级但不生成system.img镜像(把机器中的所有内容擦除并刷机)
$sudo ./flash.sh -r jetson-xavier mmcblk0p1 

更新DTB 设备树(涉及外设驱动)
将新的DTB文件"tegra194-p2888-0001-p2822-0000.dtb"复制到目录Linux_for_Tegra/kernel/dtb
$sudo ./flash.sh -r -k kernel-dtb jetson-xavier mmcblk0p1

更新内核镜像(kernel/Image 涉及外设驱动)
Xavier检索内核先判断根目录下/boot/Image 文件,此时只需要把新的内核Image文件复制到 Xavier开机后的/boot/ 目录后再重启即可,通过uname -a 查看内核信息如日期时间是否为更新的内核
$sudo ./flash.sh -r -k kernel jetson-xavier mmcblk0p1

系统备份(备份Xavier机器中的系统及全部文件至当前目录的backup.img)
$sudo ./flash.sh -r -k APP -G backup.img jetson-xavier mmcblk0p1
如何恢复使用备份的镜像:
1、上面步骤备份会生出两个文件,把其中的backup.img.raw 重新命名到bootloader/system.img(软件镜像包含用户空间的所有文件信息),backup.img 文件不被使用可以删除掉
2、运行命令重新升级机器:
$sudo ./flash.sh -r jetson-xavier mmcblk0p1 


其他指令:
sudo BOARDID=2888 FAB=400 BOARDSKU=0001 BOARDREV=K.0 ./flash.sh -r -k APP -G backup.img jetson-xavier mmcblk0p1

nx

系统镜像生成并升级(把机器中的所有内容擦除并刷机,重新制作system.img)
$sudo ./flash.sh jetson-xavier-nx-devkit-emmc mmcblk0p1 

系统完整升级但不生成system.img镜像(把机器中的所有内容擦除并刷机)
$sudo ./flash.sh -r jetson-xavier-nx-devkit-emmc mmcblk0p1 

更新DTB 设备树(涉及外设驱动)
将新的DTB文件"tegra194-p3668-all-p3509-0000.dtb"复制到目录Linux_for_Tegra/kernel/dtb
$sudo ./flash.sh -r -k kernel-dtb jetson-xavier-nx-devkit-emmc mmcblk0p1

更新内核镜像(kernel/Image 涉及外设驱动)
Xavier NX检索内核先判断根目录下/boot/Image 文件,此时只需要把新的内核Image文件复制到 Xavier NX开机后的/boot/ 目录后再重启即可,通过uname -a 查看内核信息如日期时间是否为更新的内核
$sudo cp $PWD/Image /boot/ 
$sudo reboot

系统备份(备份Xavier NX机器中的系统及全部文件至当前目录的backup.img)
$sudo ./flash.sh -r -k APP -G backup.img jetson-xavier-nx-devkit-emmc mmcblk0p1

如何恢复使用备份的镜像:
1、上面步骤备份会生出两个文件,把其中的backup.img.raw 重新命名到bootloader/system.img(软件镜像包含用户空间的所有文件信息),backup.img 文件不被使用可以删除掉
2、运行命令重新升级机器:
$sudo ./flash.sh -r jetson-xavier-nx-devkit-emmc mmcblk0p1

使用sdkmanager进行OS 升级之后,设定账号,密码之后,在板子要进行source设定

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vim /etc/apt/sources.list

#ubuntu18.4 for arm
deb http://mirrors.aliyun.com/ubuntu-ports/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu-ports/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu-ports/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ bionic-backports main restricted universe multiverse

sudo apt-get update
sudo apt-get --fix-broken install

其他情况

如果执行 sudo apt-get --fix-broken install执行成功,说明错误已经修复,可以验证一下功能是否正常使用,不必再使用sdkmanager重试,忽略错误强制退出即可。

如果执行 sudo apt-get --fix-broken install出错或者速度慢,可以尝试设置apt的代理进行加速,当然代理需要自行解决

可以设定代理的方式进行下载:
apt设置代理方法:
sudo vim /etc/apt/apt.conf
Acquire::http::Proxy "http://ip:port";   #例如Acquire::http::Proxy "http://172.16.40.113:10809";
Acquire::http::Proxy "http://username:password@ip:port";   #例如Acquire::http::Proxy "http://user:[email protected]:10809";

空间不够-系统裁剪的方法:
https://elinux.org/Jetson/FAQ/BSP/RootFS_Reduction

 sudo apt clean    # clean debs in /var/cache/apt/archives  ----》这个占用了大部分空间
 sudo rm /etc/apt/sources.list.d/*        # remove /var/cudaxxxx, /var/visonworksxxxx from apt source list
 sudo rm /var/cuda-repo-10-0-local-10.0.326/ /var/visionworks-repo/ /var/visionworks-sfm-repo/ /var/visionworks-tracking-repo/ -rf     # remove nvidia's debs

//如果空间还是不够,参考下面的脚本
#!/bin/bash
# https://elinux.org/Jetson/FAQ/BSP/RootFS_Reduction#Remove_installed_deb_packages
## Step 1, safe
sudo apt update
sudo apt autoremove -y
sudo apt clean
sudo apt remove thunderbird libreoffice-* -y
 
## Step 2, still safe but not recommended for dev use
# samples
sudo rm -rf /usr/local/cuda/samples \
    /usr/src/cudnn_samples_* \
    /usr/src/tensorrt/data \
    /usr/src/tensorrt/samples \
    /usr/share/visionworks* ~/VisionWorks-SFM*Samples \
    /opt/nvidia/deepstream/deepstream*/samples  
 
# Remove local repos
sudo apt purge cuda-repo-l4t-*local* libvisionworks-*repo -y
sudo rm /etc/apt/sources.list.d/cuda*local* /etc/apt/sources.list.d/visionworks*repo*
sudo rm -rf /usr/src/linux-headers-*
 
## Step 3, hardcore only for prod (remove GUI)
sudo apt-get purge gnome-shell ubuntu-wallpapers-bionic light-themes chromium-browser* libvisionworks libvisionworks-sfm-dev -y
sudo apt-get autoremove -y
sudo apt clean -y
 
# remove static libs (maybe cleaner to remove the "dev" packages instead)
sudo rm -rf /usr/local/cuda/targets/aarch64-linux/lib/*.a \
    /usr/lib/aarch64-linux-gnu/libcudnn*.a \
    /usr/lib/aarch64-linux-gnu/libnvcaffe_parser*.a \
    /usr/lib/aarch64-linux-gnu/libnvinfer*.a \
    /usr/lib/aarch64-linux-gnu/libnvonnxparser*.a \
    /usr/lib/aarch64-linux-gnu/libnvparsers*.a

删除cuda 不适用的库,因为deepstream使用的是动态库,因此可以删除静态库


deepstream 4.5.1 安装
https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Quickstart.html#install-the-deepstream-sdk

在NX 上安装下面的库
$ sudo apt install \
libssl1.0.0 \
libgstreamer1.0-0 \
gstreamer1.0-tools \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
libgstrtspserver-1.0-0 \
libjansson4=2.11-1

Install librdkafka

 git clone https://github.com/edenhill/librdkafka.git

$ cd librdkafka
$ git reset --hard 7101c2310341ab3f4675fc565f64f0967e135a6a
./configure
$ make
$ sudo make install

$ sudo mkdir -p /opt/nvidia/deepstream/deepstream-5.1/lib
$ sudo cp /usr/local/lib/librdkafka* /opt/nvidia/deepstream/deepstream-5.1/lib

install deepstream deb
通过sdkmanager 下载之后的软件路径:/var/cache/apt/archives/deepstream-5.1_5.1.0-1_arm64.deb

sudo apt-get install ./deepstream-5.1_5.1.0-1_arm64.deb
安装上面的deb 之前,下面的两个库要安装,主要是dpkg命令需要
libgstrtspserver-1.0-0
libgstreamer-plugins-base1.0-dev

运行deepsteam demo

cd /opt/nvidia/deepstream/deepstream-5.1/samples/configs/deepstream-app
deepstream-app -c source8_1080p_dec_infer-resnet_tracker_tiled_display_fp16_nano.txt
deepstream-app -c source12_1080p_dec_infer-resnet_tracker_tiled_display_fp16_tx2.txt

deepstream4.5.1-运行修改的RTSP:source1_usb_dec_infer_resnet_int8-修改如下


################################################################################
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
################################################################################

[application]
enable-perf-measurement=1
perf-measurement-interval-sec=5
#gie-kitti-output-dir=streamscl

[tiled-display]
enable=1
rows=1
columns=1
width=1280
height=720

[source0]
enable=1
#Type - 1=CameraV4L2 2=URI 3=MultiURI 4=RTSP
type=3
#uri=file://../../streams/sample_1080p_h264.mp4
#uri=rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0 //大华摄像头,没有成功
uri=rtsp://admin:[email protected]:554/ch01.264   //huaxiazongheng这个可以
num-sources=1
#drop-frame-interval=2
gpu-id=0
# (0): memtype_device   - Memory type Device
# (1): memtype_pinned   - Memory type Host Pinned
# (2): memtype_unified  - Memory type Unified
cudadec-memtype=0

[sink0]
enable=1
#Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming 5=Overlay
type=5
sync=0
display-id=0
offset-x=0
offset-y=0
width=0
height=0
overlay-id=1
source-id=0

[sink1]
enable=0
type=3
#1=mp4 2=mkv
container=1
#1=h264 2=h265 3=mpeg4
codec=1
#encoder type 0=Hardware 1=Software
enc-type=0
sync=0
bitrate=2000000
#H264 Profile - 0=Baseline 2=Main 4=High
#H265 Profile - 0=Main 1=Main10
profile=0
output-file=out.mp4
source-id=0

[sink2]
enable=0
#Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming 5=Overlay
type=4
#1=h264 2=h265
codec=1
#encoder type 0=Hardware 1=Software
enc-type=0
sync=0
bitrate=4000000
#H264 Profile - 0=Baseline 2=Main 4=High
#H265 Profile - 0=Main 1=Main10
profile=0
# set below properties in case of RTSPStreaming
rtsp-port=8554
udp-port=5400

[osd]
enable=1
border-width=2
text-size=15
text-color=1;1;1;1;
text-bg-color=0.3;0.3;0.3;1
font=Serif
show-clock=0
clock-x-offset=800
clock-y-offset=820
clock-text-size=12
clock-color=1;0;0;0

[streammux]
##Boolean property to inform muxer that sources are live
live-source=1
batch-size=1
##time out in usec, to wait after the first buffer is available
##to push the batch even if the complete batch is not formed
batched-push-timeout=40000
## Set muxer output width and height
width=1280
height=720
## If set to TRUE, system timestamp will be attached as ntp timestamp
## If set to FALSE, ntp timestamp from rtspsrc, if available, will be attached
# attach-sys-ts-as-ntp=1

# config-file property is mandatory for any gie section.
# Other properties are optional and if set will override the properties set in
# the infer config file.
[primary-gie]
enable=1
model-engine-file=../../models/Primary_Detector/resnet10.caffemodel_b30_gpu0_int8.engine
#Required to display the PGIE labels, should be added even when using config-file
#property
batch-size=1
#Required by the app for OSD, not a plugin property
bbox-border-color0=1;0;0;1
bbox-border-color1=0;1;1;1
bbox-border-color2=0;0;1;1
bbox-border-color3=0;1;0;1
interval=0
#Required by the app for SGIE, when used along with config-file property
gie-unique-id=1
config-file=config_infer_primary.txt

[tests]
file-loop=0

刷机参考:
https://blog.csdn.net/dsp1406790497/article/details/108585951

芯片架构参考:
https://developer.nvidia.com/zh-cn/blog/%E6%8E%A8%E5%87%BA%E5%85%A8%E7%90%83%E6%9C%80%E5%B0%8F%E7%9A%84-ai-%E8%B6%85%E7%BA%A7%E8%AE%A1%E7%AE%97%E6%9C%BAjetson-xavier-nx/

demo 如何展示

REF:
https://latelee.blog.csdn.net/article/details/113750340

https://blog.csdn.net/Tosonw/article/details/104154090

REF:
https://developer.nvidia.com/deepstream-sdk
https://developer.nvidia.com/isaac-sdk
https://m.ximalaya.com/keji/15270742/

你可能感兴趣的:(英伟达nx-1)