• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • 3 月 19 日下午 2 點,鎖定 NVIDIA AI 網絡中文專場。立即注冊觀看
    人工智能/深度學習

    使用 NVIDIA EGX 在 NVIDIA Jetson Xavier NX 微型服務器上部署 AI 應用程序

    現代對敏捷能力和零停機時間持續創新的期望要求改變嵌入式和邊緣設備軟件的開發和部署方式。在邊緣采用諸如微服務、容器化和容器編排之類的云原生范式是前進的方向,但是部署、管理和安全問題的復雜性阻礙了擴展。

    NVIDIA EGX 平臺是一個基于云的 Kubernetes 和基于容器的軟件平臺,使您能夠快速、輕松地為基于 NVIDIA Jetson 的微服務器或邊緣物聯網系統提供資源。通過為 Jetson Xavier NX 邊緣設備帶來 EGX 云本地敏捷性,企業可以使用與云革命相同的技術和工作流來大規模構建、部署和管理邊緣設備。

    在本文中,您將了解云原生軟件棧的關鍵組件,如何在 Jetson Xavier NX 開發者工具包上安裝 EGX DIY 堆棧,并使用它在邊緣輕松部署智能視頻分析( IVA )應用程序。

    人工智能容器

    如今的企業正在將智能轉移到邊緣,并在地理位置不同的存在點( POP )部署邊緣基礎設施,以實現更低的網絡成本和更好的響應時間。容器是敏捷軟件開發和交付的促成因素,并節省帶寬以幫助降低傳輸成本。

    EGX 從 NGC 運行 AI 容器,這是一個為 AI 和數據分析軟件優化的集線器。 NGC 旨在簡化和加速端到端工作流。 NGC 擁有 150 多個企業級容器, 100 多個模型,以及行業特定的 sdk 和 Helm 圖表,可以部署在本地、云中或邊緣。您可以按原樣使用軟件或“優化和定制”,使部署功能強大的軟件或構建定制的解決方案變得容易,并收集見解以實現業務價值。

    EGX 還包括對 NGC 私人注冊 的訪問,在這里您可以安全地存儲您獨特的 IP 和定制的解決方案,以最大的安全性在邊緣、本地或云上共享和部署。

    庫伯涅茨

    Kubernetes 是一個容器編排系統,是當今云計算和企業中最活躍的開源項目之一。它已經成為阿德事實標準和邊緣計算的重要基礎,具有自動容器部署和自我修復的特性。

    EGX 云本地軟件策略的一個核心組件是使 GPUs 具有 Kubernetes 的彈性。 EGX 包括一個 GPU 操作符,它自動安裝和配置 Kubernetes 集群中使用 GPUs 所需的所有組件。

    這大大簡化了第 0 天的 IT 操作,并完全自動化了第 1 天的操作… n 操作。所有必需的組件,如 NVIDIA 驅動程序、 NVIDIA 容器運行時、 Kubernetes 設備插件和監控都是容器化的,并作為服務在 Kubernetes 上運行,這導致 IT 部門只需為 CPU 和 GPU 節點管理一個映像。

    舵面圖

    Helm 圖表是 Kubernetes 推薦的包格式,因為它允許您通過單擊按鈕和幾個 CLI 命令在 Kubernetes 集群上輕松地配置、部署和更新應用程序。

    NGC 托管這些庫伯內特斯準備好的頭盔圖表來部署強大的第三方軟件。 DevOps 還可以在 NGC 上推送和共享他們的舵圖,這樣團隊就可以利用一致、安全和可靠的環境來加快開發到生產周期。

    安裝 EGX 2 . 0 堆棧

    NVIDIA Jetson Xavier NX 開發工具包 將超級計算機的性能提升到了極致,在 15W 的功率和較小的外形尺寸下,提供了 21 個頂級的 AI 計算。 Jetson Xavier NX 非常適合高性能人工智能系統,如商業機器人、醫療器械、智能相機、高分辨率傳感器、自動光學檢測、智能工廠和其他物聯網嵌入式系統。

    對 Jetson Xavier NX 的云本地支持現在也可以通過 EGX 軟件棧的最新更新實現。 Jetson Xavier NX 開發工具包上的這個堆棧是 NVIDIA 功能和性能驗證的參考設計,可以在嵌入式設備上實現快速的云本地部署。

    下面是在 Jetson Xavier NX 開發工具包上安裝 egx2 . 0 堆棧的步驟。成功安裝后, EGX 2 . 0 平臺 就緒 Jetson Xavier NX 開發工具包包括以下內容:

    • NVIDIA Jetpack SDK 4 . 4
    • 管理版本 1 . 17 . 5
    • 舵手/舵柄 3 . 1 . 0
    • NVIDIA 容器運行時 1 . 0 . 1-dev

    在本文中,我們使用了一個帶有 Jetson Xavier NX 開發工具包的 32gb microSD 卡。

    設置開發工具包并安裝 JetPack 4 . 4

    JetPack 包含在 Jetson 平臺上構建 AI 應用程序的庫、工具和核心操作系統。有關設置 Jetson Xavier NX 開發人員工具包和安裝 Jetpack4 . 4 的詳細信息,請參閱 Jetson Xavier NX 開發工具包入門

    更新 Docker 配置

    編輯 Docker 守護程序配置,添加以下行并保存文件:

    "default-runtime" : "nvidia"

    下面是一個配置塊示例:

    $ sudo nano /etc/docker/daemon.json { "runtimes": { "nvidia": { "path": "nvidia-container-runtime", "runtimeArgs": [] } }, "default-runtime" : "nvidia"
    }

    重新啟動 Docker 守護程序:

    sudo systemctl daemon-reload && sudo systemctl restart docker

    正在驗證 Docker 默認運行時

    驗證 Docker 默認運行時為 NVIDIA :

    $ sudo docker info | grep -i runtime

    以下是示例輸出:

    Runtimes: nvidia runc
    Default Runtime: nvidia

    安裝 Kubernetes 1 . 17 . 5 版

    在開始安裝之前,請確保 Docker 已啟動并已啟用:

    $ sudo systemctl start docker && sudo systemctl enable docker

    安裝立方體、 kubeadm 和 kubectl :

    $ sudo apt-get update && sudo apt-get install -y apt-transport-https curl
    $ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
    $ sudo mkdir -p /etc/apt/sources.list.d/

    創建庫伯內特斯列表文件:

    $ sudo nano /etc/apt/sources.list.d/kubernetes.list

    在庫伯內特斯列表歸檔并保存:

    deb https://apt.kubernetes.io/ kubernetes-xenial main

    安裝立方體、 kubectl 和 kubeadm :

    $ sudo apt-get update
    $ sudo apt-get install -y -q kubelet=1.17.5-00 kubectl=1.17.5-00 kubeadm=1.17.5-00
    $ sudo apt-mark hold kubelet kubeadm kubectl

    初始化 Kubernetes 集群以作為主服務器運行

    禁用交換:

    $ sudo swapoff -a

    初始化群集:

    $ sudo kubeadm init --pod-network-cidr=10.244.0.0/16

    輸出顯示了將 pod 網絡部署到集群所需執行的命令,以及加入集群的命令。

    使用輸出指令,運行以下命令:

    $ mkdir -p $HOME/.kube
    $ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    $ sudo chown $(id -u):$(id -g) $HOME/.kube/config

    將 pod 網絡附加組件安裝到控制平面節點。使用 calico 作為 pod 網絡附加組件:

    $ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

    確保所有吊艙都已啟動并運行:

    $ kubectl get pods --all-namespaces

    以下是示例輸出:

    NAMESPACE???? NAME????????????????????????????????? ?????READY?? STATUS??? RESTARTS?? AGE
    kube-system?? kube-flannel-ds-arm64-gz28t??????????????? 1/1???? Running?? 0????????? 2m8s
    kube-system?? coredns-5c98db65d4-d4kgh????? ?????????????1/1???? Running?? 0????????? 9m8s
    kube-system?? coredns-5c98db65d4-h6x8m?????????????????? 1/1???? Running?? 0????????? 9m8s
    kube-system?? etcd-#yourhost???????????????????????????? 1/1???? Running?? 0????????? 8m25s
    kube-system?? kube-apiserver-#yourhost?????????????????? 1/1???? Running?? 0????????? 8m7s
    kube-system?? kube-controller-manager-#yourhost????????? 1/1???? Running?? 0????????? 8m3s
    kube-system?? kube-proxy-6sh42?????????????????????????? 1/1???? Running?? 0????????? 9m7s
    kube-system?? kube-scheduler-#yourhost?????????????????? 1/1???? Running?? 0????????? 8m26s

    get nodes 命令顯示主節點已啟動并準備就緒:

    $ kubectl get nodes

    以下是示例輸出:

    NAME STATUS ROLES AGE VERSION
    #yournodes Ready master 10m v1.17.5

    因為您使用的是單節點 Kubernetes 集群,所以默認情況下,集群無法在控制平面節點上調度 pod 。在控制平面節點上調度 pods 。必須使用以下命令刪除污點:

    $ kubectl taint nodes --all node-role.kubernetes.io/master-

    有關詳細信息,請參見 安裝 kubeadm

    安裝舵柄/舵柄 3 . 1 . 0

    下載 Helm 3 . 1 . 0 :

    $ sudo wget https://get.helm.sh/helm-v3.1.0-linux-arm64.tar.gz
    $ sudo tar -zxvf helm-v3.1.0-linux-arm64.tar.gz
    $ sudo mv linux-arm64/helm /usr/local/bin/helm

    有關詳細信息,請參見 舵手釋放赫爾姆概論

    驗證成功的 EGX 2 . 0 安裝

    要驗證 EGX 堆棧是否按預期工作,請按照以下步驟創建 pod yaml 文件。如果 getpods 命令顯示 pod 狀態為 completed ,則說明安裝成功。您還可以驗證 CUDA 是否成功運行 – 樣品. yaml 驗證輸出是否顯示 Result = PASS 。

    創建一個 pod yaml 文件,添加以下內容,并將其另存為樣品. yaml :

    $ sudo nano cuda-samples.yaml

    添加以下內容并將其另存為 CUDA – 樣品. yaml :

    apiVersion: v1
    kind: Pod
    metadata: name: nvidia-l4t-base
    spec: restartPolicy: OnFailure containers: - name: nvidia-l4t-base image: "nvcr.io/nvidia/l4t-base:r32.4.2" args: - /usr/local/cuda/samples/1_Utilities/deviceQuery/deviceQuery

    編譯 CUDA 示例以從 pod 驗證:

    $ cd /usr/local/cuda/samples/1_Utilities/deviceQuery
    $ sudo make
    $ cd ~

    創建示例 GPU pod :

    $ sudo kubectl apply -f cuda-samples.yaml

    檢查樣本盒是否已創建:

    $ kubectl get pods

    以下是示例輸出:

    nvidia-l4t-base 0/1 Completed 2m

    驗證示例 pod 日志以支持 CUDA 庫:

    kubectl logs nvidia-l4t-base

    以下是示例輸出:

    /usr/local/cuda/samples/1_Utilities/deviceQuery/deviceQuery Starting...
    ?CUDA Device Query (Runtime API) version (CUDART static linking)
    Detected 1 CUDA Capable device(s)
    ?
    Device 0: "Xavier"
    ? CUDA Driver Version / Runtime Version????????? 10.2 / 10.2
    ? CUDA Capability Major/Minor version number:??? 7.2
    ? Total amount of global memory:???????????????? 7764 MBytes (8140709888 bytes)
    ? ( 6) Multiprocessors, ( 64) CUDA Cores/MP:???? 384 CUDA Cores
    ? GPU Max Clock rate:??????????????????????????? 1109 MHz (1.11 GHz)
    ? Memory Clock rate:???????????????????????????? 1109 Mhz
    ? Memory Bus Width:????????????????????????????? 256-bit
    ? L2 Cache Size:???????????????????????????????? 524288 bytes
    ? Maximum Texture Dimension Size (x,y,z)???????? 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
    ? Maximum Layered 1D Texture Size, (num) layers? 1D=(32768), 2048 layers
    ? Maximum Layered 2D Texture Size, (num) layers? 2D=(32768, 32768), 2048 layers
    ? Total amount of constant memory:?????????????? 65536 bytes
    ? Total amount of shared memory per block:?????? 49152 bytes
    ? Total number of registers available per block: 65536
    ? Warp size:???????????????????????????????????? 32
    ? Maximum number of threads per multiprocessor:? 2048
    ? Maximum number of threads per block:?????????? 1024
    ? Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
    ? Max dimension size of a grid size??? (x,y,z): (2147483647, 65535, 65535)
    ? Maximum memory pitch:????????????????????????? 2147483647 bytes
    ? Texture alignment:???????????????????????????? 512 bytes
    ? Concurrent copy and kernel execution:????????? Yes with 1 copy engine(s)
    ? Run time limit on kernels:???????????????????? No
    ? Integrated GPU sharing Host Memory:??????????? Yes
    ? Support host page-locked memory mapping:?????? Yes
    ? Alignment requirement for Surfaces:??????????? Yes
    ? Device has ECC support:??? ????????????????????Disabled
    ? Device supports Unified Addressing (UVA):????? Yes
    ? Device supports Compute Preemption:??????????? Yes
    ? Supports Cooperative Kernel Launch:??????????? Yes
    ? Supports MultiDevice Co-op Kernel Launch:????? Yes
    ? Device PCI Domain ID / Bus ID / location ID:?? 0 / 0 / 0
    ? Compute Mode:
    ???? < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
    ?
    deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 10.2, CUDA Runtime Version = 10.2, NumDevs = 1
    Result = PASS

    有關 EGX 軟件版本和安裝指南的更多信息,請參閱 Jetson Xavier NX DevKit 的 EGX Stack – v2 . 0 安裝指南

    用例:簡化 IVA 應用程序的部署

    在基于 EGX 的 Jetson Xavier NX 上使用 NVIDIA 深溪 構建和部署 AI 驅動的 IVA 應用程序和服務。 deepstreamsdk 提供了一個具有 TLS 安全性的可擴展加速框架,可以部署在邊緣并連接到任何云。

    在您的 EGX Jetson 設備上創建一個 DeepStream Helm 圖表目錄。

    $ mkdir deepstream-helmchart

    在/ deepstream helmchart 中創建一個模板目錄來存儲 Kubernetes 清單:

    $ mkdir -p deepstream-helmchart/templates

    創建圖表. yaml 文件,添加以下內容,并將其保存到/ deepstream helmchart 目錄中:

    $ nano chart.yaml apiVersion: v1
    name: deepstream-helmchart
    version: 1.0.0
    appVersion: 0.1

    將新文件創建為配置映射. yaml 在/ deepstream helmchart / templates 中添加以下內容:

    $ nano configmap.yaml
    ?
    apiVersion: v1
    kind: ConfigMap
    metadata:
    ? name: deepstream-configmap
    data:
    ? source4_1080p_dec_infer-resnet_tracker_sgie_tiled_display_int8.txt: |-
    ??? # Copyright (c) 2018 NVIDIA Corporation.? All rights reserved.
    ??? #
    ??? # NVIDIA Corporation and its licensors retain all intellectual property
    ??? # and proprietary rights in and to this software, related documentation
    ??? # and any modifications thereto.? Any use, reproduction, disclosure or
    ??? # distribution of this software and related documentation without an express
    ??? # license agreement from NVIDIA Corporation is strictly prohibited.
    ?
    ??? [application]
    ??? enable-perf-measurement=1
    ??? perf-measurement-interval-sec=5
    ??? #gie-kitti-output-dir=streamscl
    ?
    ??? [tiled-display]
    ??? enable=1
    ??? rows=2
    ?? ?columns=2
    ??? width=1280
    ??? height=720
    ??? gpu-id=0
    ??? #(0): nvbuf-mem-default - Default memory allocated, specific to a platform
    ??? #(1): nvbuf-mem-cuda-pinned - Allocate Pinned/Host cuda memory, applicable for Tesla
    ??? #(2): nvbuf-mem-cuda-device - Allocate Device cuda memory, applicable for Tesla
    ??? #(3): nvbuf-mem-cuda-unified - Allocate Unified cuda memory, applicable for Tesla
    ??? #(4): nvbuf-mem-surface-array - Allocate Surface Array memory, applicable for Jetson
    ??? nvbuf-memory-type=0
    ?
    ??? [source0]
    ??? enable=1
    ??? #Type - 1=CameraV4L2 2=URI 3=MultiURI 4=RTSP
    ??? type=3
    ??? uri=file://../../streams/sample_1080p_h264.mp4
    ??? num-sources=4
    ??? #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
    ??? sync=0
    ??? codec=1
    ??? bitrate=4000000
    ??? rtsp-port=8554
    ??? udp-port=5400
    ??? gpu-id=0
    ??? nvbuf-memory-type=0
    ?
    ??? [sink1]
    ??? enable=0
    ??? type=3
    ??? #1=mp4 2=mkv
    ??? container=1
    ??? #1=h264 2=h265
    ??? codec=3
    ??? sync=0
    ??? bitrate=2000000
    ??? output-file=out.mp4
    ??? source-id=0
    ??? gpu-id=0
    ?
    ??? [sink2]
    ??? enable=0
    ??? #Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming
    ??? type=4
    ??? #1=h264 2=h265
    ??? codec=1
    ??? sync=1
    ??? bitrate=1000000
    ??? cuda-memory-type=1
    ??? # set below properties in case of RTSPStreaming
    ??? rtsp-port=8554
    ??? udp-port=5400
    ??? gpu-id=0
    ?
    ??? [osd]
    ??? enable=1
    ??? gpu-id=0
    ??? border-width=1
    ??? 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
    ??? nvbuf-memory-type=0
    ?
    ??? [streammux]
    ??? gpu-id=0
    ??? ##Boolean property to inform muxer that sources are live
    ??? live-source=0
    ??? batch-size=4
    ??? ##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=1920
    ??? height=1080
    ??? ##Enable to maintain aspect ratio wrt source, and allow black borders, works
    ??? ##along with width, height properties
    ??? enable-padding=0
    ??? nvbuf-memory-type=0
    ?
    ??? # 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
    ??? gpu-id=0
    ??? model-engine-file=../../models/Primary_Detector/resnet10.caffemodel_b4_int8.engine
    ??? batch-size=4
    ??? 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
    ??? gie-unique-id=1
    ??? nvbuf-memory-type=0
    ??? config-file=config_infer_primary.txt
    ?
    ??? [tracker]
    ??? enable=1
    ??? tracker-width=640
    ??? tracker-height=384
    ??? ll-lib-file=/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_mot_iou.so
    ??? #ll-lib-file=/opt/nvidia/deepstream/deepstream-4.0/lib/libnvds_nvdcf.so
    ??? ll-lib-file=/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_mot_klt.so
    ??? #ll-config-file required for DCF/IOU only
    ??? #ll-config-file=tracker_config.yml
    ??? #ll-config-file=iou_config.txt
    ??? gpu-id=0
    ??? #enable-batch-process applicable to DCF only
    ??? enable-batch-process=1
    ?
    ??? [secondary-gie0]
    ??? enable=1
    ??? model-engine-file=../../models/Secondary_VehicleTypes/resnet18.caffemodel_b16_int8.engine
    ??? gpu-id=0
    ??? batch-size=16
    ??? gie-unique-id=4
    ??? operate-on-gie-id=1
    ??? operate-on-class-ids=0;
    ??? config-file=config_infer_secondary_vehicletypes.txt
    ?
    ??? [secondary-gie1]
    ??? enable=1
    ??? model-engine-file=../../models/Secondary_CarColor/resnet18.caffemodel_b16_int8.engine
    ??? batch-size=16
    ??? gpu-id=0
    ??? gie-unique-id=5
    ??? operate-on-gie-id=1
    ??? operate-on-class-ids=0;
    ??? config-file=config_infer_secondary_carcolor.txt
    ?
    ??? [secondary-gie2]
    ??? enable=1
    ??? model-engine-file=../../models/Secondary_CarMake/resnet18.caffemodel_b16_int8.engine
    ??? batch-size=16
    ??? gpu-id=0
    ??? gie-unique-id=6
    ??? operate-on-gie-id=1
    ??? operate-on-class-ids=0;
    ??? config-file=config_infer_secondary_carmake.txt
    ?
    ??? [tests]
    ??? file-loop=1

    設置電源模式并固定 Jetson 設備上的時鐘:

    $ sudo nvpmodel -m 2
    $ sudo jetson_clocks

    在 Jetson 設備上安裝 DeepStream 頭盔圖表:

    $ helm install --name-template deepstream deepstream-helmchart/

    驗證 DeepStream 吊艙是否啟動并運行:

    $ kubectl get pods
    NAME READY STATUS RESTARTS AGE
    deepstream-76787ffbf7-mfwk7 1/1 Running 0 1m

    查看 DeepStream 吊艙日志并查看性能:

    $ kubectl logs <deepstream-podname>

    以下是示例輸出:

    $ kubectl logs deepstream-9f8b6b68d-rc5lq
    **PERF: 101.42 (100.29) 101.42 (100.29) 101.42 (100.29) 101.42 (100.29)

    清理 Jetson 設備上的 DeepStream 頭盔圖表:

    $ helm del deepstream

    結論

    在本文中,您了解了云原生軟件棧的關鍵組件。我們還向您展示了如何在 Jetson Xavier NX 開發工具包上安裝 EGX DIY 堆棧。使用它可以輕松地在邊緣部署 IVA 應用程序。

    要了解其他 Jetson Xavier NX 支持的集裝箱化、預先訓練的 AI 模型的更多信息,請參見 NGC 。這些模型可以作為您的人工智能應用程序開發的構建塊,并幫助您在今天的邊緣計算中實現下一個飛躍!

    0

    標簽

    人人超碰97caoporen国产