当前位置 博文首页 > cumtchw:nvidia jetson question and answer

    cumtchw:nvidia jetson question and answer

    作者:[db:作者] 时间:2021-07-28 15:08

    有关nvidia jetson的一些问题以及问题答案,简单备份。

    1.Here, https://forums.developer.nvidia.com/c/agx-autonomous-machines/jetson-embedded-systems/70

    With a filed topic, it’s easy to sync internally on the same thread and keep tracked.

    2.after set?the OC limit to 10A, it worked !no warning about OC throtted, also the?

    Bug?200724396?

    ?which CPU frequency is vibrated ,now is fix to maximum!

    3.Pls let customer try again and feedback the new latency.

    3.1. If customer is using MM LL API,? check if they enabled the corresponding code of below two settings in MM LL -??jetson_multimedia_api/samples/00_video_decode

    --max-perf

    --disable-dpb

    3.2.?If customer is using GStreamer decoder plugin -?nvv4l2decoder in GStreamer pipeline or DeepStream, check if they enabled two options below.

    $?gst-inspect-1.0 nvv4l2decoder

    ...

    disable-dpb

    enable-max-performance

    4.MLM: https://docs.nvidia.com/jetson/l4t-multimedia/l4t_mm_test_group.html

    5.Camera已经匹配的。需要有驱动支持的,和DTS适配,https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/jetson_xavier_camera_soft_archi.html#wwconnect_header,让他们先看下doc。no cameras available,可能和DTC没有适配有关

    6.NVINSIGHT需要完整的qdrep文件,和log里对应问题的时间点

    7.DLA for?YOLOV3. their detection model is also YoloV3. At first, when U moved the model onto DLA, the many Leaky_Relu layers fell back to GPU and the perf was not good, the WAR solution we gave is: changing Leaky_Relu to Relu and re-train their YoloV3 model.

    For other?way, if they have enough data and is willing to re-train their model, they can adopt above WAR solution as well, otherwise, they could wait for JP4.6 release, with JP4.6, DLA will support Leaky_Relu natively, then customer does not need to modify their YoloV3 to run on DLA.

    8.MEM 占用。TensorRT的内存消耗主要来自一下几部分:?

    cuDNN, CUDA, cublas的库加载、对应cuda kernel加载、已经它们对应的handler所占用的一些内存???????????===> 只要在一个进程里,这些内存在线程间是共享的

    9.模型运行时,改模型weight所在内存,模型运行过程中分配的一些存放feature map(例如输出、输出、TRT内部存feature map)的内存???========> 这个和模型本身有关,和是否单/多线程无关。所以,这些和?单/多?线程是无关的。

    10.环境温度45-70区间,CPU和GPU主频没有降,检测帧率降低,怎么解释。没有锁频。

    11.?https://docs.nvidia.com/jetson/l4t-multimedia/index.html

    12. https://forums.developer.nvidia.com/t/multi-stream-rtsp-gstreamer-opencv/121142/13,这个里面有code,可以参考下,gst+opencv,用硬件解码

    13 https://github.com/jkjung-avt/tensorrt_demos,这个repo在jetson测试过yolov3v4的COCO map,看着比较靠谱。就是有个yolo-layer的plugin,可以参考eval-yolo的脚本做些调整试试

    14 NX量产核心板引脚线序和开发者套件的核心板线序一样吗?一样,差异是工艺。

    15. 这个配置界面里面的30W 6COREMAXN在配置上有什么区别?

    具体差别看如下表

    16?MAXN是不是最高频路,最大核数,最大功率?

    是最大功耗,相关参数均为最大值

    17 我们需要开启最大功率,应该怎么操作?

    AGX xaiver :nvpmodel 0, jetson_clocks, 其他说明参见L4T power management部分

    18 我测试了一下MAXN下的性能,在relue模式下8batch,耗时(AGX ?: ?NX? =? ???13.4 : 22.66),这个设置模式下也没有达到1:2的关系。

    最终测试加速比和TRT优化,IO读写都有关系,2倍上下都可能,都是正常的

    19 AGX与NX评估过程中发现性能并不成倍数关系。

    [Martin]: 测试条件是什么?是什么配置?请详细描述。

    ????? 硬件环境:AGX使用友商设备,NX使用开发板。

    [Martin]: https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/power_management_jetson_xavier.html#wwpID0E0VO0HA?

    Xavier 30W_ALL的情况下, GPU 频率只有?900MHz.

    NX 15W_6 Core的情况下,GPU频率有1100MHz.

    所以,虽然XavierGPU? core 核数比NX 更多?(4 vs 3),但是频率低,所以,得到的性能是差不多的。

    另,Xavier / NXGPU算力主要由Tensor Core提供,Tensor Core只支持FP16 ?INT8,所以,实际使用中最好用FP16INT8

    20 模组芯片过热了

    AO@87C GPU@88.5C?PMIC@100C AUX@85C CPU@90.5C?thermal@87.7C

    参考如下链接?查看限频温度

    https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/power_management_jetson_xavier.html#wwpID0E0DG0HA?

    21 还是关于GPU内存的编码的问题:

    在已经有了GPU mem下,有一个思路就是去把GPU数据copy到1生成的EGL buffer中。

    问题:将GPU数据到1生成EGL buffer 的过程是如何实现的?

    附件是个如下pipeline的例子。可以参考里面的cudaMemcpy()或VIC的方法来拷贝。

    ?

    Multiple NV12 buffers created with createNvBuffer() ----> Compose (VIC/CUDA) ---> output an NV12 buffer created with createNvBuffer()

    ?

    Demonstrate three ways to do the composition:
    1. VIC

    > enaled by comment VIC_COMPOSE definition
    > note: vic can compose max 16 source buffers

    2. CUDA with cudaMemcpy2DAsync

    > enable this option by comment VIC_COMPOSE and uncomment COMPOSE_WITH_CUDA_MEMCPY

    3. CUDA with CUDA kernel

    > enable this option by comment both VIC_COMPOSE and COMPOSE_WITH_CUDA_MEMCPY


    Build and Run
    1. Put thie sample under?jetson_multimedia_api on Jetson device

    $ cp?/usr/src/jetson_multimedia_api ~/
    $ cd?~/jetson_multimedia_api/samples/
    $ tar xpf?nvbuffer_compose.tgz

    2. Generate a NV12 srcouce image

    ? $ cd nvbuffer_cuda_composite/
    ? $ gst-launch-1.0 videotestsrc pattern=colors ?num-buffers=1 ! 'video/x-raw, framerate=25/1,width=1920,height=1080,format=(string)NV12' ! timeoverlay halignment=center valignment=center text="Streamtime:" shaded-background=true ! filesink location=src_1920_1080.nv12 -v -e

    3. Build and Run

    $ make
    $ ./nvbuffer_composite

    Note: this sample need to run on display terminal since it needs to render the output

    22??NvBufferCreateEx() 创建后?然后再把这个hardware memory映射到CUDA给前面的CUDA/GPU操作作为输出buffer ?是如何实现?

    可以参考03_video_cuda_enc,需要映射到EGL,再用CUDA处理

    ??????? /* map DMA fd to eglImage for CUDA processing */

    ??????? ctx.eglimg = NvEGLImageFromFd(ctx.eglDisplay, buffer->planes[0].fd);

    ??????? /* render rectangle by CUDA */

    ??????? HandleEGLImage(&ctx.eglimg);

    23?我的需求是将GPU空间内的NV12图像映射?hardware memory ,我就得到了buffer->plane[0].fd 然后encodeFromFd编码,

    映射这个功能如何实现,还是需要EGL吗??有demo或者我参考jetson-mulitmedia-api的哪个文件?

    一般从CPU buffer通过convert映射到hardware mem得到fd,就是jpeg你现在的用法。在已经有了GPU mem下,有一个思路就是去把GPU数据copy到1生成的EGL buffer中。但如果基于小图映射fd,你需要不停的创建不同大小的fd,用完在释放, 像@Martin Chi说明的,可能会产生内存碎片,性能也不一定好

    24?NX平台编码业务需求

    NX平台编码,我参考的demo是jetson-multimedia_api 中的05_jpeg_encode中的case 2

    ????? 我记的当时讨论的结果是,你们拿到ROI坐标后到原始NV12 buffer中去crop 做JPEG encoder。

    JPEG encoder里带crop的API - https://docs.nvidia.com/jetson/l4t-multimedia/classNvJPEGEncoder.html#a0b6e471b32eadba119e81bd25d3d6aad?,这样可以节省内存拷贝,对性能最好。

    关于问题1,一开始讨论的方案是:?NvBufferCreateEx() 创建hardware memory for JPEG encoder,然后再把这个hardware memory映射到CUDA给前面的CUDA/GPU操作作为输出buffer,但是因为你输出的分辨率是随机变化的,所以,后来觉的这个方法不太可行。而且,再主循环内分配释放内存非常影响performance,而且容易造成内存碎片。

    所以,请考虑上面提的crop –> encoding的方案。

    25 cuda 上实现nv12图像相似变换的问题

    ????? --问题4会议中讨论的NV12ToBgr(U8packager)的demo提供一下。

    26 nv12_resize.cu现在输入要求跨距是32的整数倍,我们希望输入、输出宽高没有这个限制。如果跨距不是32的整数倍,会出现输出图像异常现象。

    [Martin]: 因为CUDA texture的限制,必须要32对齐。可以通过加padding使pitch 32对齐

    27 你们解码输出的YUV数据需要缓存到对这帧所有的inference 结束才释放吗?

    根据上次开会讨论的,你的pipeline里有多级模型,后面的模型得到前面detect到的BBOX后需要回缓存的YUV数据里去抠图吗?

    需要的,不过这里用的是对大图的引用,内存不增长。

    28 关于内存使用

    a. 我们用附件(改成到?jetson_multimedia_api/samples/00_video_decode)改动测试了1/2/4/8/10路解码,内存占用如下,10路时占用约??500MB

    测试command:

    $ ./video_decode H264 -s 20 --max-perf --disable-dpb --disable-rendering ../../data/Video/sample_outdoor_car_1080p_10fps.h264

    编解码这边,我们实际测试平均每路内存消耗也是50M左右。

    ?

    b.如上次所说,第一个TensorRT instance一般占~1.5GB内存,在同一个进程里再新建新的TensorRT instance 给其它的model,新消耗的内存就会明显很少(主要是输入输出buffer, weights等,根据经验一般?100~200MB),所以,6个TensorRT模型内存占用应该?~2.8GB

    所以,解码?+ 6 个TRT 模型?+ 开机后系统内存?(300 ~ 400MB) = 3.7 GB,对于8GB NX,还有4.3GB内存,所以,你们可以再分析看看你们程序里哪里还可以节省内存

    这个内存消耗与我们实际测试也是一致的。

    29 nv12_resize.cu支持Y通道与UV通道输入地址不连续。

    [Martin]: ?https://github.com/NVIDIA/cuda-samples/blob/master/Samples/NV12toBGRandResize/nv12_resize.cu#L71?里面的YUV就是分别映射的,没有要求YUV必须连续。

    30 nv12_resize.cu与nv12_to_bgr_planar.cu合并,这样子我们可以节省中间缓存。

    [Martin]: ?resize是基于CUDA texture实现的,而nv12_to_bgr是基于global CUDA memory + CUDA kernel实现的,二者机制不一样,不能融合。

    31? nv12_to_bgr_packager(BGRBGR),数据类型为CV_8UC3。

    [Martin]: ?这个你可以对应着修改,把输出float改成char即可

    32 在CUDA上实现nv12的图像相似性变换。

    [Martin]: ?可以基于npp (https://docs.nvidia.com/cuda/npp/group__affine__transform__batch.html)nppiWarpAffineBatch_8u_C3R() ?nppiWarpAffineBatch_8u_C3R_Ctx()实现。

    33 onnx parser参考这个就可以啊,https://github.com/NVIDIA/TensorRT/blob/master/samples/opensource/sampleOnnxMNIST/sampleOnnxMNIST.cpp

    calibration 参考这个 https://github.com/NVIDIA/TensorRT/blob/master/samples/opensource/sampleINT8/sampleINT8.cpp

    trtexec只是个工具啊,你可以用onnx parser转engine

    https://github.com/Tianxiaomo/pytorch-YOLOv4,这个是官方推荐的,建议看看这个,有问题还有资源能问问

    34 在NX上跑算法时 发现板子上自带的EMMC存储空间不够只有16G,而我们这边算法工程师说需要至少32G的空间,这样就没法使用啊,还是你们那边有什么好的建议?

    通过sdkmanager,显示系统和sdk就需要25G,光sdk也是需要13G

    ——没有25G,全下来10G多吧,删除一些不用的目录

    刷device用不到host

    就是host上网,是通过host下载,然后usb直接copy到device

    执行删除命令:

    sudo apt clean

    sudo apt-get purge chromium-browser thunderbird fonts-noto-cjk libreoffice-common containerd snapd

    ?

    这两步执行下,看空间剩多少,如果不够。再执行:

    sudo apt-get purge libqt5webkit5 ubuntu-wallpapers-bionic freepats libreoffice-writer libicu60 libreoffice-calc vim-runtime libflite1 libperl5.26 libmozjs-52-0 humanity-icon-theme samba-libs kwin-data perl-modules-5.26 light-themes libjavascriptcoregtk-4.0-18 chromium-browser-l10n

    这些都可以删

    sudo apt-get purge libqt5webkit5 ubuntu-wallpapers-bionic freepats libreoffice-writer libicu60 libreoffice-calc vim-runtime libflite1 libperl5.26 libmozjs-52-0 humanity-icon-theme samba-libs kwin-data perl-modules-5.26 light-themes libjavascriptcoregtk-4.0-18 chromium-browser-l10n

    这个,你挑一部分试下;这个要一点点删,删的时候,看下有哪些关联项,命令行还能进么。最好是,刷完系统,先删这些,然后再sdk

    cs