YH Hsu
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    2
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Jetson AGX Xavier 系統環境設定2_Docker安裝或從源程式碼編譯 ###### tags: `Edge AI` `Nvidia` `Jetson` `System Setup` ![](https://i.imgur.com/S5QFcnE.png =800x) ## NVIDIA Jetson 平台佈署相關筆記 ### 基本環境設定 - [Jetson AGX Xavier 系統環境設定1_在windows10環境連接與安裝](https://hackmd.io/@YungHuiHsu/HJ2lcU4Rj) - [Jetson AGX Xavier 系統環境設定2_Docker安裝或從源程式碼編譯](https://hackmd.io/k-lnDTxVQDWo_V13WEnfOg) - [NVIDIA Container Toolkit 安裝筆記](https://hackmd.io/wADvyemZRDOeEduJXA9X7g) - [Jetson 邊緣裝置查詢系統性能指令jtop](https://hackmd.io/VXXV3T5GRIKi6ap8SkR-tg) - [Jetson Network Setup 網路設定](https://hackmd.io/WiqAB7pLSpm2863N2ISGXQ) - [OpenCV turns on cuda acceleration in Nvidia Jetson platform<br>OpenCV在Nvidia Jetson平台開啟cuda加速](https://hackmd.io/6IloyiWMQ_qbIpIE_c_1GA) ### 模型佈署與加速 - [[Object Detection_YOLO] YOLOv7 論文筆記](https://hackmd.io/xhLeIsoSToW0jL61QRWDcQ) - [Deploy YOLOv7 on Nvidia Jetson](https://hackmd.io/kZftj6AgQmWJsbXsswIwEQ) - [Convert PyTorch model to TensorRT for 3-8x speedup<br>將PyTorch模型轉換為TensorRT,實現3-8倍加速](https://hackmd.io/_oaJhYNqTvyL_h01X1Fdmw?both) - [Accelerate multi-streaming cameras with DeepStream and deploy custom (YOLO) models<br>使用DeepStream加速多串流攝影機並佈署客製(YOLO)模型](https://hackmd.io/@YungHuiHsu/rJKx-tv4h) - [Use Deepstream python API to extract the model output tensor and customize model post-processing (e.g., YOLO-Pose)<br>使用Deepstream python API提取模型輸出張量並定製模型后處理(如:YOLO-Pose)](https://hackmd.io/@YungHuiHsu/rk41ISKY2) - [Model Quantization Note 模型量化筆記](https://hackmd.io/riYLcrp1RuKHpVI22oEAXA) --- # Nvidia官方導覽文件[Hello AI World](https://github.com/dusty-nv/jetson-inference) 內含手把手教學 - 中文介紹 [Hello AI World (一):環境準備與安裝](https://ithelp.ithome.com.tw/articles/10299233?sc=rss.iron) ## System Setup 在Video Walkthroughs一節有提供導覽影片 - [Jetson AI Fundamentals - S3E1 - Hello AI World Setup](https://www.youtube.com/watch?v=QXIwdsyK7Rw&list=PL5B692fm6--uQRRDTPsJDp4o0xbzkoyf8&index=10) ### Setting up Jetson with JetPack 系統環境安裝,需要要先安裝JetPack在Jetson裝置上 :::info 在JetPack 安裝完成後[(Setting up Jetson with JetPack)](https://github.com/dusty-nv/jetson-inference/blob/master/docs/jetpack-setup-2.md),依照需求可以選擇 1. 使用docker建立container([Running the Docker Container](https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-docker.md)) 3. 或著可選擇直接在Jetson上,從源程式碼編譯後,進行安裝與執行建立專案([Building the Project from Source](https://github.com/dusty-nv/jetson-inference/blob/master/docs/building-repo-2.md)) ::: ## 使用Container [Running the Docker Container](https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-docker.md) ### NVIDIA Docker安裝 見[NVIDIA Container Toolkit 安裝筆記](https://hackmd.io/wADvyemZRDOeEduJXA9X7g) ### Running the Docker Container 安裝完NVIDIA Docker後,按官方文件指引,啟用Container 在dusty-nv/jetson-inference已經幫忙把啟用container的複雜設定寫成bash腳本,在執行`docker/run.sh`的時候,就會根據你安裝的jetpack版本載入對應的inference server所需的container版本 - Launching the Container ``` $ git clone --recursive https://github.com/dusty-nv/jetson-inference $ cd jetson-inference $ docker/run.sh ``` `docker/run.sh`會根據你當前安裝的JetPack-L4T的版本,自動從DockerHub中提取正確的容器標簽,並掛載適當的數據目錄和設備,以便你可以在容器中使用相機/顯示器/ect。它還會提示你下載DNN模型,如果你還沒有這樣做的話,這些模型會被掛載到容器中去。這個初始設置只做一次。(備註:jetson-inference是以[L4T PyTorch](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-pytorch)為基礎建立的) 如果順利建立成功的話,`docker/run.sh`會自動幫你把資料路徑掛載到主機 - Mounted Data Volumes * jetson-inference/data (stores the network models, serialized TensorRT engines, and test images) * jetson-inference/python/training/classification/data (stores classification training datasets) * jetson-inference/python/training/classification/models (stores classification models trained by PyTorch) * jetson-inference/python/training/detection/ssd/data (stores detection training datasets) * jetson-inference/python/training/detection/ssd/models (stores detection models trained by PyTorch) 如果要自訂掛載路徑的話 ``` $ docker/run.sh --volume /my/host/path:/my/container/path # these should be absolute paths ``` #### 容器建立失敗 :::warning 手上的Jetson AGX Xavier 只有32G,安裝完NVIDIA container等可用空間剩下6G左右 文件提到JetPack version 必須與L4T version一致(the version of JetPack-L4T that you have installed on your Jetson needs to match the tag ) 目前刷機時安裝的是JetPack 5.1版, 必須搭配L4T R35.2.1的container版本,但容量不夠(image拉回來解壓縮後導致系統爆掉進不去才發現,只好又重新刷機一次) ![](https://i.imgur.com/bLj5OEV.png =600x) ::: 可能解法有三: - [ ] 從燒機 把JetPack 降板為4.6.1, 就可以安裝只有1G左右的L4T version - (待嘗試)在Windows環境下以vmware建立Ubuntu系統作為host來刷機 - [ ] 2. 安裝在SD卡/外接硬碟上 - [X] 不建立container 直接安裝在機器上 - 見 Building the Project from Source操作指引 ## 直接在Jetson上編譯程式碼 [Building the Project from Source](https://github.com/dusty-nv/jetson-inference/blob/master/docs/building-repo-2.md) 由於JetPack 5.1版,搭配的L4T R35.2.1太過肥大,無法安裝在只有32G空間的AGX Xavier,所以我選擇直接在Jetson上編譯安裝環境 跟著官方文件指引,依序輸入下方指令進行編譯 ### Cloning the Repo ``` $ sudo apt update $ sudo apt install git cmake libpython3-dev python3-numpy $ git clone --recursive https://github.com/dusty-nv/jetson-inference $ cd jetson-inference $ git submodule update --init ``` - `git submodule update --init` 在Git中,子模組是一個獨立的Git倉庫,可以被包含在其他Git倉庫中,用於管理外部的依賴庫或模組。通常情況下,當一個Git倉庫包含子模組時,Git只會記錄子模組的版本號或引用,而不會自動下載或更新子模組的內容。 當使用`git submodule update --init`時,Git會到當前目錄中的.gitmodules文件中查找所有已定義的子模組,然後進行以下操作: - 初始化子模組:如果子模組尚未被初始化,則會下載子模組的內容並將其嵌套在當前目錄中。 - 更新子模組:如果子模組已經被初始化,但其版本號或引用已經發生變化,則會根據.gitmodules文件中的版本號或引用更新子模組的內容。 `git submodule update --init`命令用於初始化和更新Git子模組,可以確保當前目錄中的子模組與.gitmodules文件中定義的版本號或引用相符。這個命令通常用於當一個Git倉庫中包含多個子模組時,簡化子模組的管理過程。 #### Python Development Packages ` libpython3-dev `為python3 的開發工具包,以綁定Python C API #### Configuring with CMake ``` $ mkdir build $ cd build $ cmake ../ $ make -j$(nproc) ``` - `cmake ../` :::spoiler `cmake`是一個跨平台的程式碼構建工具,可以自動生成各種平台所需的構建文件,例如Makefile或Visual Studio項目檔案。cmake可以根據CMakeLists.txt文件中的指示,生成可執行文件或庫文件等。 當使用`cmake ../`時,cmake會到當前目錄的上一層目錄中尋找CMakeLists.txt文件,然後根據該文件中的指示建立和管理專案。這種方式通常用於在一個單獨的建置目錄中進行構建。這種方式的優點是可以避免在原始碼目錄中產生過多的構建文件和中間文件,而且可以讓多個建置目錄同時共用同一份原始碼。當然,也可以在原始碼目錄中進行構建,這種方式則可以避免在多個建置目錄之間進行文件複製。 ::: - `make -j$(nproc)` :::spoiler make是一個編譯工具,它可以自動根據Makefile文件中的指示進行編譯和生成可執行文件。make在編譯過程中會根據Makefile文件中的依賴關係自動編譯所需的所有文件,然後生成最終的可執行文件。但是,如果在編譯過程中出現了依賴關係錯誤,或者需要編譯大量的文件,編譯過程就可能需要很長的時間。 為了加速編譯過程,可以使用make -j指令。 -j選項告訴make同時執行多個編譯任務,以便充分利用CPU資源,加快編譯速度。數字參數指定同時執行的任務數量。例如,make -j2表示同時執行2個編譯任務。 `$(nproc)`是一個內建的Linux指令,可以顯示CPU的數量。當使用-j選項時,$(nproc)可以告訴make使用多少個CPU核心執行編譯任務,以便最大化利用CPU資源。 總結來說,make -j$(nproc)指令可以讓make同時執行多個編譯任務,以便充分利用CPU資源,加快編譯速度,並且會自動根據系統CPU的數量動態調整執行緒數量,從而最大限度地發揮CPU效能,進而加速編譯過程。 ::: #### Compiling the Project ``` $ make $ sudo make install $ sudo ldconfig ``` - `make install` :::spoiler 在C/C++項目中,源代碼文件需要經過編譯和鏈接才能生成可執行文件或庫文件。make命令可以根據Makefile文件中的指示,自動執行編譯和鏈接操作,生成最終的目標文件。 使用make命令時,通常需要先創建一個Makefile文件,其中包含了程式碼的依賴關係和編譯指令等信息。然後,通過運行make命令,Make工具會自動檢測需要重新編譯的文件,並執行相應的編譯操作。 當使用sudo make install時,make命令會將編譯後生成的目標文件安裝到系統中,通常是安裝到/usr/local目錄或指定的其他目錄中。這樣,使用者就可以在系統中運行該程序或使用該庫文件。 ::: - `sudo ldconfig` :::spoiler 當使用sudo ldconfig時,ldconfig命令會重新加載共享庫緩存,從而讓系統能夠找到新安裝的共享庫文件。這個命令通常用於在安裝新的共享庫文件後更新系統的共享庫緩存。 總結來說,make命令是一個用於編譯和構建C/C++程式碼的命令,可以根據Makefile文件中的指示自動執行編譯和鏈接操作。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 ``` ### (可選)下載模型 如果有需要的話,可以下載Nvidia提供的預訓練模型 ![](https://i.imgur.com/i0sTHhG.png =400x) ``` $ cd jetson-inference/tools $ ./download-models.sh ``` 如果上述指令執行有問題 可至[Model Download Mirror](https://github.com/dusty-nv/jetson-inference/releases/tag/model-mirror-190618)手動下載後執行以下指令 ``` cd <jetson-inference>/data/networks/ tar -zxvf <model-archive-name>.tar.gz ``` ### (可選)安裝pytorch 如果有需要做transfer learning的話,可選擇性安裝 ![](https://i.imgur.com/1xsW1Wc. =400x) ``` $ cd jetson-inference/build $ ./install-pytorch.sh ``` 以上程序完成後就可以進入下個導覽頁面[Classifying Images with ImageNet](https://github.com/dusty-nv/jetson-inference/blob/master/docs/imagenet-console-2.md)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully