OmniXRI-Jack
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • 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 No publishing access yet

        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.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        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 New
      • Engagement control
      • Make a copy
      • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy 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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    3
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 如何在Windows安裝Linux(WSL2+Ubuntu)及Docker來執行OpenVINO和DL Streamer ![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBxP0kXqCYhW1BJI8fBHiGZAkM3KyQYbG24vVYtwh-TKZTV7cv8hjBZKMBIKk33kS7dskUQZiqvrFsB5queUaMmBw8BpUI5ICxdMufb4pd_RtmyCThX7Znar4Tzkiciuq-PiJ837a8Cs_2sHEsAAJjsU5ysSniNDx3uyg7pvAYKIV_a6fteW7l0RKV/s1656/win10_wsl2_docker_openvino_Fig00.jpg) 以往想在Microsoft Windows上運行Liunx(如Ubuntu),可能要透過VMware或Virtualbox這類虛擬化工具來安裝,不過除非你使用的是付費的進階版本,不然通常是無法調用本機端的GPU(不管NVIDIA或INTEL內顯、外顯)資源。後來微軟也看到這個商機於是在2016年順勢在Win10上推出適用於Linux的子系統(Windows Subsystem for Linux, WSL),讓使用者可輕易使用Linux作業系統的核心功能,包括常見的Ubuntu, openSUSE, Debian, Kali等。2019年推出WSL2時,除了一般Liunx基本的命令列工具(如Bash)外,甚至也可以運行圖形化視窗界面(如X Window)。如此一來就能讓使用者在Windows和Linux兩種作業系統上任意切換,不用再安裝其它虛擬化工具了。 隨著Win11上市,WSL2亦有較大幅度的更新,直接就能從Windows APP Store下載,除了Ubuntu 18.04.5 LTS, 20.04.5 LTS, 22.04.1 LTS可選擇外,另外還有Debian, Kali, fedora remix等多種環境。同時也開始對本地端的GPU有明顯的支援,包括NVIDIA及INTEL(含內顯HD Graphics, Xe,外顯Iris Xe系列),這樣對開發AI應用程式有很大的幫助,就可以使用像TensorFlow, PyTorch這類框架來進行模型訓練及使用像Nvidia TensorRT, Intel OpenVINO這樣的推論工具加速運算。 接下來就帶著大家一步一步把開發環境架設起來。如果你的電腦已經是安裝Ubuntu桌面圖形使用者介面(Desktop GUI)系統,只是想安裝Intel OpenVINO, Docker和DL Streamer來練習,那麼可以略過下面第1, 2, 3, 7節的說明。 ## 1. 確認Windows環境及Intel內顯驅動 為了確定可以在Windows上安裝WSL2和調用Intel GPU資源,首先要確認Windows的版本。若已是Win 11 (22000.x以上)版本則可略過這個步驟,若是Win 10則建議更新21H2 (19000.x以上)版本。如果不知自己的Windows版本可用滑鼠左鍵點擊工作列左下角【開始】鍵,再點擊齒輪圖示的【設定】鍵,進入設定頁面點選【系統】,再捲動左側目錄,進入【關於】子頁面,查看【Windows規格】即可得知「版本」及「OS組建」內容。若版本不夠新則回到上一層【更新與安全】將Windows更新到最新版本。 ![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjU_xVaFMWRm16D3whR5nH3-ALRvxOnAIVbMRk7xs2IbqRC_Z7aCkff-7Cb_0675o_yr0GW4R61iBIRY8dCTbAgz0oo0E8uHCz_8QtPcr0dcDOt4pRxnNvbiC7-ACHVG3pgNM1v_H8djkIz6KLcKfgotv3wKxNOs2I53arl_TONjxdGsDAXggdD_YYW/s1658/win10_wsl2_docker_openvino_Fig01.jpg) Fig. 1 檢查Windows版本程序圖。(OmniXRI整理製作,2022/9/21) 接下來要確認Intel的內顯(HD Graphics)驅動程式版本是否滿足。以滑鼠右鍵點擊工作列【開始】鍵,進入【裝置管理員】頁面,選擇【顯示卡】下Intel(R) UHD Graphics XXX(這裡會隨每個人的CPU不同而有不同)。接著以滑鼠右鍵點擊,進到【內容】頁面下的【驅動程式】子頁面,確認版本是否大於30.0.100.9955。若否,則到下列網址下載最新的GPU驅動程式。 https://www.intel.com/content/www/us/en/download/19344/intel-graphics-windows-dch-drivers.html ![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyOP7Hf4uQ_SKEg2ZNW1HUpTJultYyG3Vl8ScIfXZL9JMqWP8n7nsRTrcAhoDC2BAlFyRFbEaHQ4Y__1btKEs4ppBu7fUP2VugskBssbvz0n3_UosJ-iIElz1EYQ4e5sFap764DHq4jN7g-JFfKhOfqag5gb5rxFs78MEmtz6d0rE1BtdW9znJKXPl/s1658/win10_wsl2_docker_openvino_Fig02.jpg) Fig. 2 檢查Intel GPU驅動程式版本流程圖。(OmniXRI整理製作,2022/9/21) **完成Windows更新和Intel顯示卡的驅動程式更新後,記得重新開機,確保系統能正確運作**。 ## 2. 使用WSL2安裝Ubuntu 在Win 10, Win 11上安裝Ubuntu最簡單的方式就是使用Microsoft Store,查詢Ubuntu,就會顯示可安裝的版本,這裡我們選用 Ubuntu 20.04.5 LTS(可依需求自行調整),點擊後就會開始下載(約525MB)及安裝,會依網速不同要等待一段時間。 ![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnUFizO3ai7Rtof6jYtqHSKlN2awLB_T9eYFr-9B_V0D1AjXmQFDfV9gfkjamm-WtC1IYDD0bZ_YcoZ0w2Qrey5HqnKHqlynk8GjQjB5yDZP6zzZZz7ilBao4HJ63W5PWpxCWGz9tgBO0MCoRZq8iF4DIzWDhQrumf8pi_wY0AFVoKUwGfayq44jbW/s1658/win10_wsl2_docker_openvino_Fig03.jpg) Fig. 3 從Microsoft Store安裝WSL2用Ubuntu流程圖。(OmniXRI整理製作,2022/9/21) 安裝完成後,可先略過【啟動】。系統會自動在程式清單上加入已安裝的Ubuntu的選項。啟動時要以滑鼠右鍵點擊,選擇【更多】,再以「以系統管理員身份執行」,方便後面進到Ubuntu後的命令操作。若想要多個版本的Ubuntu,可依上述步驟逐一安裝不同版的Ubuntu。 第一次啟動Ubuntu時會要求輸入帳號、密碼,這裡不用輸入和Windows登入時相同的帳號密碼,可任意輸入。進入後就得到和Ubuntu命令列模式的操作環境。若想了解WSL2安裝及執行的資訊,可啟動Powershell,輸入「wsl --list -v」,就會看到 「Ubuntu-20.04」的名稱及狀態正在Running。如果找不到Powershell.exe路徑的朋友,可點選工作列上的放大鏡圖示,輸入powershell進行查詢就可得到相關執行名稱及路徑。 ## 3. 幫Ubuntu搬個家 一般WSL安裝Ubuntu後預設會存在C槽使用者路徑下,類似下列路徑 C:\Users\user_name\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04LTS_79rhkp1fndgsc\LocalState\ext4.vhdx ,剛開始可能不會有什麼問題,但隨著安裝更多工具到Ubuntu後,C槽就很快不夠用了,尤其是C槽是SSD且容量不大(一般可能只有256GB到512GB)的朋友。但不幸地是WSL並沒有提供安裝在別的磁碟的設定,只能用wsl下指令搬家的方式來解決,這樣我們就能把Ubuntu搬到容量較大的機械式硬碟上,不用擔心被塞爆。 以「以系統管理員身份執行」啟動Powershell。假設D槽為搬家的目的地,首先將原有的Ubuntu匯出一個壓縮檔(*.tar)並取消註冊,然後在D槽建立一個新的路徑,例如D:\Ubuntu_20_04。接著重新匯入到新路徑,刪除壓縮檔,便完成搬家工作。 ```powershell wsl --export Ubuntu-20.04 d:\ubuntu.tar wsl --unregister Ubuntu-20.04 mkdir d:\Ubuntu_20_04 wsl --import Ubuntu-20.04 d:\Ubuntu_20_04 d:\ubuntu.tar del d:\ubuntu.tar ``` 完成後會發現Ubuntu虛擬磁碟檔案ext4.vhdx已被搬到D:\Ubuntu_20_04路徑下了,這樣我們就可放心大膽的安裝其它工具。此時重新啟動Ubuntu時會發現變成使用「root」的身份進入,不是原先我們設的那個帳號、密碼,此時就要修改Windows的Registry Key來復原。 可點選工作列上的放大鏡圖示,輸入regedit進行查詢,點選「登入編輯程式」,找到下列機碼: \HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\ ,然後進到「DefaultUid」將「數值資料」項目內容改成 3e8 (16進制),再重新開啟Ubuntu就能以先前設定的帳號、密碼登入了。 ## 4. 安裝OpenCL函式庫 為了一些Intel加速計算功能,所以要安裝OpenCL,首先啟動Ubuntu,再執行下列指令,進行安裝。 ```bash cd ~ sudo apt-get update sudo apt install ocl-icd-opencl-dev ``` 安裝intel-gmmlib, intel-opencl-icd, intel-level-zero-gpu套件,包含下列動作。 * 建立臨時路徑 * 下載所需安裝套件包 * 驗證套件包SHA256正確性 * 安裝套件包 ```bash mkdir neo cd neo wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.12037.1/intel-igc-core_1.0.12037.1_amd64.deb wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.12037.1/intel-igc-opencl_1.0.12037.1_amd64.deb wget https://github.com/intel/compute-runtime/releases/download/22.37.24175/intel-level-zero-gpu-dbgsym_1.3.24175_amd64.ddeb wget https://github.com/intel/compute-runtime/releases/download/22.37.24175/intel-level-zero-gpu_1.3.24175_amd64.deb wget https://github.com/intel/compute-runtime/releases/download/22.37.24175/intel-opencl-icd-dbgsym_22.37.24175_amd64.ddeb wget https://github.com/intel/compute-runtime/releases/download/22.37.24175/intel-opencl-icd_22.37.24175_amd64.deb wget https://github.com/intel/compute-runtime/releases/download/22.37.24175/libigdgmm12_22.1.8_amd64.deb wget https://github.com/intel/compute-runtime/releases/download/22.37.24175/ww37.sum sha256sum -c ww37.sum sudo dpkg -i *.deb ``` ## 5. 建立及啟用Python虛擬環境 使用如下指令來安裝及啟用Python虛擬環境,方便隔離不同Python操作環境。假設建立一個OpenVINO的Python操作環境。 執行 source openvino_env/bin/activate 啟用虛擬環境,成功進入後,提示字符會變成(openvino_env) user_name@computer_name:~$。 執行 deactivate 可離開虛擬環境。 ```bash cd ~ sudo apt-get update sudo apt install python3-venv python3 -m venv openvino_env source openvino_env/bin/activate ``` ## 6. 使用Python虛擬環境安裝OpenVINO 目前OpenVINO有支援很多種安裝方式,其中最方便的就是在Python虛擬環境下透過PyPi (pip install)安裝。安裝前先更新一下pip工具包,由於後續我們會用到很多OpenVINO開發工具及AI框架,所以這裡要安裝開發者版本(openvino-dev)及指定所需AI框架(caffe, kaldi, mxnet, onnx, pytorch, tensorflow, tensorflow2)。完成安裝後可簡單測試一下,包含OpenVINO 2022.1 Runtime是否安裝正確及模型優化工具(mo)是否能正確啟動。 ```bash source openvino_env/bin/activate python -m pip install --upgrade pip pip install openvino-dev[tensorflow2,onnx,pytorch] python -c "from openvino.runtime import Core" mo -h ``` 不過依上述步驟完成安裝後會發現並不支援Myriad X(即VPU, NCS2)硬體推論,只支援CPU和iGPU,要特別注意。如果想知道更多Python安裝的問題,可以參考一下小弟先前寫的文章「[使用PyPi(pip install)安裝Intel OpenVINO 2022.1填坑心得](https://omnixri.blogspot.com/2022/08/pypi-pip-install-intel-openvino-20221.html)」[4]。 ## 7. 安裝Ubuntu圖形使用者介面 由於剛才安裝的Ubuntu只有命令列模式,所以若要處理及顯示影像類(如*.jpg, *.mp4)的內容就要有圖形使用者介面(Graphic User Interface, GUI),即視窗桌面環境。還好Windows已有準備一套陽春的虛擬桌面系統XLaunch (VcXsrv) 可以讓WSL2的Ubuntu連接。 不過在連接前,還要先進到Ubuntu,依照下列步驟操作,花點時間下載及安裝一些套件。 ```bash cd ~ sudo apt-get update sudo apt-get upgrade sudo apt-get install x11-apps ``` 接著在家目錄下建立一個.bash_login檔案 ```bash nano ~/.bash_login ``` 並輸入以內容,再按Ctrl+x,按Y鍵,再按Enter鍵,存檔並結束編輯程式。 ```bash # For WSL2 export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0.0 export LIBGL_ALWAYS_INDIRECT=1 ``` 再來安裝xfce4桌面程式,這要花滿久的,和網速和電腦速度有關。完成安裝後就可先把Ubuntu關閉。 ```bash sudo apt-get install xfce4-terminal sudo apt-get install xfce4 ``` 再來回到Windows,點擊工作列上放大鏡示,查找「XLaunch」,點擊啟動後,會出現如下圖所示畫面,依序設定即可啟動一個虛擬顯示器等著WSL2的Ubuntu來連結,此時會看到一個全黑的視窗被開啟,先不要關閉。其中步驟9可幫大家把這組參數存成一個檔案(config.xlaunch)放在Windows桌面,那下次雙擊圖示時就能自動開啟,不用每次都重設。 ![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJBqCpMmIFZ5M4WvlbWWx5mfgeDV0xaX43IRZkHrdUFNhmmhS9F9BRnYTTQgHH7n9uHh0TJMLCjgXQNbonMtoyVT_dfL0JOEBEazj-7PRVEUkmWRWNq_7sMja93d-oyEuo6zbkAeYLGj8iH--ljSiLziIdzpjfqveWkUK1evCHrLK2oLFVWGN2wQu/s1658/win10_wsl2_docker_openvino_Fig04.jpg) Fig. 4 啟用XLaunch(VcXsrv)虛擬桌面流程圖。(OmniXRI整理製作,2022/9/21) 接著重新啟動Ubuntu進到命令列模式,執行下列指令,開始連接XLaunch (VcXsrv)虛擬桌面。若連接成功會出現如Fig. 5畫面。 這個指令以後每次重開 Ubuntu 需要桌面時都會用到,所以可以背下來,方便後續使用。 ```bash sudo startxfce4 ``` ![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1LuCFN1uFRhvUVfkZy8jtKu0PFqX0ApkImGCtvKw-_euyq499s8mc_H7cdVg_aA1aIpSc0KO17WWMjkOYspCD9_m4jrkb-MgHZw9GhSw3C7T5HsueRbbYIw0BgV2Pmeg3mJW3DuUUPzrlIHBjNoGkxaLFWCUaqsMBmBkpPdNQTncMOlubGPxHpJp1/s1658/win10_wsl2_docker_openvino_Fig05.jpg) Fig. 5 XLaunch (VcXsrv)虛擬桌面啟動畫面。(OmniXRI整理製作,2022/9/21) 畫面左上方選單[Applications]點擊後就會出現許多已安裝好的功能及服務,而下方快捷鍵列左邊第二個圖示,即為進入命令列模式,就可以直接從這裡切換視窗和命令列模式,而不用再回到剛才啟動Ubuntu的那個命令列視窗了。 本來到這裡以為就收工了,但事情總沒有這麼順利。這個桌面系統實在太陽春,連基本的影像、影片瀏覽工具都沒有,也沒有像Ubuntu程式市集可以下載所需工具。幾經查找,可以透過安裝其它套件包來讓這個桌面變得更像Ubuntu。於是選擇了xubuntu-desktop進行安裝,這個套件包超大,可能要安裝一個小時甚至更久,要有點耐心等候。 ```bash sudo apt install xubuntu-desktop ``` 待完成後,關閉 XLaunch 和 Ubuntu 視窗。重新啟動 XLaunch 和 Ubuntu,在命令列執行「sudo startxfce4」,XLaunch就會出現Fig. 5的畫面。此時再去點擊左上角[Applications]選單時,就會發覺多了很多常用的功能,和標準的 Ubuntu GNOME很接近,此時就算完 WSL2 + Ubuntu 的桌面環境設置了。 ## 8. 測試iGPU運行OpenVINO 再來就能實測一下從XLaunch桌面系統,進到命令模式運行OpenVINO的範例程式了。不過一進到命令列時發覺使用者變成root了,這時要使用「su username」命令來切換使用者,不然家目錄(~)所指的路徑就不對了。而這裡的username是指在第2節建立的使用者名稱,輸入指令時請自行修改。 在運行OpenVINO前不要忘了要先啟動剛才設好的Python虛擬環境。為了方便測試,首先下載和設置OpenVINO Open Model Zoo,再下載推論所需的影片檔案(face-demographics-walking-and-pause.mp4)及模型(human-pose-estimation-0005),最後就能以範例程式(human_pose_estimation_demo.py)來進行人員動作偵測,其中參數 -d 即為指定推論硬體,可自行切換為CPU或GPU來比較。若二種裝置都能推論就表示OpenVINO開發環境及硬體相關設置成功。 ```bash su username cd ~ source openvino_env/bin/activate git clone https://github.com/openvinotoolkit/open_model_zoo.git pip install open_model_zoo/demos/common/python cd open_model_zoo/demos/human_pose_estimation_demo/python wget https://storage.openvinotoolkit.org/data/test_data/videos/face-demographics-walking-and-pause.mp4 omz_downloader --name human-pose-estimation-0005 python human_pose_estimation_demo.py -m ~/open_model_zoo/demos/human_pose_estimation_demo/python/intel/human-pose-estimation-0005/FP32/human-pose-estimation-0005.xml -at ae -i face-demographics-walking-and-pause.mp4 -d GPU ``` 以下就證明一下在Windows上使用WSL2 + Ubuntu 20.04 LTS + XLaunch 桌面 + OpenVINO 2022.1是可以完美運作的。如Fig. 6左上所示,為使用Intel Core i7-9750H (9代CPU)測試結果,而Fig. 6左下則是i7內顯GPU UHD-630執行結果,而右側圖是運行時GPU的負載圖,可以看到已接近滿載在運行,成功在WSL2調用iGPU。 ![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZvN1fGNDbccMWzAcsUjCWLw98PpMP-NP4ELPghS5Koy67cZ_5KYXPNxTPZcnSKHbKuCxEILCc2mkXx9754q_IcmRMT_q2fXVMtxnkhJ3PdmkdCcHirg4GrLM5lC3GNbyzlTGek_CL0ygWKsBR9jY6DRSEVD9Z9hVq0pOEDi9XFJkH1YPToaaj1ZhP/s1681/win10_wsl2_docker_openvino_Fig06.jpg) Fig. 6 OpenVINO以CPU和iGPU運行姿態估測程式結果比較圖。(OmniXRI整理製作,2022/9/21) 這裡大家或許會質疑為何CPU推論會比iGPU快,正常在純Linux環境下iGPU應該會快過9代CPU才對。猜想可能是因為開了虛擬桌面顯示運行中的視訊畫面造成,因為在只使用CPU運行時,iGPU也使用了約10~15%的GPU運算資源。 ## 9. 安裝Docker到WSL2上的Ubuntu Intel OpenVINO提供了多種安裝方式,直接從Docker Hub拉(Pull)一個映像檔(Image File)來安裝,也是另一個不錯的選擇,尤其是遇到要安裝像 DL Streamer, DL Workbench 等高階應用時。一般Docker只能在Linux環境運行,因為這裡我們已經在Windows上把Ubuntu (Linux) 開發環境架好,所以更方便Docker的安裝了。 安裝時,首先重新更新系統,移除舊的版本的docker及相關套件,確保系統不會產生衝突。接著開始安裝docker。完成後可檢查一下是否可顯示目前工作版本,若可以顯示則表示安裝無誤。 ```bash sudo apt-get update sudo apt-get remove docker docker-engine docker.io sudo apt install -y docker.io docker --version ``` 再來要使用systemctl來啟用docker的服務,此時會出現下列錯誤訊息。 ```bash System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down ``` 這是因為WSL2系統不認得 systemctl 和 systemd 這些指令,所以我們需要安裝另一個套件來解決。 ```bash cd ~ git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git cd ubuntu-wsl2-systemd-script bash ubuntu-wsl2-systemd-script.sh --force ``` 當看到「成功: 已經儲存指定的值。」的訊息後,表示安裝完成,可輸入「exit」加Enter鍵離開Ubuntu,或者直接關掉Ubuntu命令列視窗亦可。然後重新啟動Ubuntu,執行「pa aux」指令來測試,若能看到一堆工作執行序狀態,就表示systemctrl已可成功運行。再來就可以準備啟動並檢查docker是否已在運行狀態,最後可按「Ctrl + C」強迫停止顯示docker狀態。 ```bash sudo systemctl start docker sudo systemctl status docker ``` 接著可以從docker hub下載hello-world的映像檔來測試。通常如果直接下「run image_name」的指令,若找不到指定的映像檔(如hello-world)時,則系統會自動去下載並執行。我們亦可「images」指令來檢查已下載的映像檔清單及相關版本。 ```bash sudo docker run hello-world sudo docker images ``` ## 10. 以Docker安裝OpenVINO和DL Streamer 由於Intel OpenVINO 2022.1版已將DL Streamer功能從自動安裝中移除,含標準版本及開發者版本,因此如果想要使用時,必須自行手動安裝,其中使用docker來安裝算是比較簡潔的作法。這裡僅用比較簡易的方式來安裝Docker作示範,若需要其它方式更完整安裝說明,可參考Docker官網[6]。 首先啟動Ubuntu命令列視窗,執行下列命令,即可自動安裝 devel 版本(即2022.1.0-ubuntu20-devel OpenVINO 開發者版本)。此版本包含完整的GStreamer Pipeline Framework元件、範例程式(samples)及模型下載器(model downloade)等工具。由於映像檔案非常大(將近4GB),**所以務必要在網路速度良好的環境下安裝**,不然會等太久。完成後可檢查一下安裝清單是否已加入dlstreamer。 ```bash sudo systemctl start docker sudo docker run -it --rm dlstreamer/dlstreamer:devel /bin/bash sudo docker images ``` 安裝完成後,可關閉再開啟 XLaunch 桌面環境的命令列工作視窗,執行下列指令就可運行 OpenVINO 和 DL Streamer 了。這裡會發現和剛才的運行(run)指令好像一樣。是的沒錯,當執行卻找不到映像檔時,就會自動變成下載安裝動作了。如果成功進入,會發現提示命令字串變成「dlstreamer@xxx:~$」,此時再檢查 /opt/intel 或 /opt/intel/dlstreamer 就會看到已經安裝好的 OpenVINO 和 DL Streamer 工作目錄了。 ```bash sudo systemctl start docker sudo docker run -it --rm dlstreamer/dlstreamer:devel /bin/bash ls /opt/intel ls /opt/intel/dlstreamer ``` ![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn2nZmyUj5aivzItqbkOnebEZXKefpg9CCjQ8cf76Ot8DvVxPRUHC24QbWvAyPuBmJjdSMO1wBHIxcVifU4bM0Yils1KFhY49vSftB0qnwMKf28Bsozpua8rnINGVjrcVWpn55yZfWjUuTbIglEceMjZg5Ga1tL39Y0rHDAdPftVVWHttBr6XwWld-/s1658/win10_wsl2_docker_openvino_Fig07.jpg) Fig. 7 啟用docker,運行OpenVINO結果圖。(OmniXRI整理製作,2022/9/21) ## 小結 恭禧各位朋友,終於把WSL2, Ubuntu命令列環境, XLaunch (VcXsrv)桌面環境, Docker容器環境, Intel OpenVINO 和 DL Streamer 開發環境架好了。再來就可以大展手腳,開始來玩 OpenVINO 和 DL Streamer 的各項實驗。如果你還想了解如何建置模型開發的AI框架及訓練的環境,就留待下回分解了! ## 參考文獻 [1] Intel, Meduim / OpenVINO-Toolkit - Accelerating the performance of AI applications on Windows Subsystem for Linux with Intel’s iGPU and OpenVINO™ toolkit https://medium.com/openvino-toolkit/accelerating-the-performance-of-ai-applications-on-windows-subsystem-for-linux-with-intels-igpu-a148c60e6ade [2] Ubuntu, Install Ubuntu on WSL2 on Windows 10 https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-10 [3] Microsoft, WSL基本令命令 https://learn.microsoft.com/zh-tw/windows/wsl/basic-commands [4] 許哲豪,使用PyPi(pip install)安裝Intel OpenVINO 2022.1填坑心得 https://omnixri.blogspot.com/2022/08/pypi-pip-install-intel-openvino-20221.html [5] 李俊諭,Window10 建置Ubuntu(WSL2)與GUI桌面配置筆記 https://hackmd.io/@JYU/B1zmv1MCU [6] Docker, Install Docker Desktop on Ubuntu https://docs.docker.com/desktop/install/ubuntu/ [7] Intel, docker hub - dlstreamer/dlstreamer - Intel® Deep Learning Streamer (Intel® DL Streamer) Pipeline Framework https://hub.docker.com/r/dlstreamer/dlstreamer

    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
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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