日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

TX2刷机和软件安装过程记录

發布時間:2024/3/12 编程问答 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 TX2刷机和软件安装过程记录 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

    • 準備
    • 使用SDKmanager刷機
    • 手動安裝SDK
    • SSD啟動
      • 1. 格式化已安裝的 SSD
      • 2. 從SD卡復制到SSD
      • 3. 啟用從 SSD 啟動
    • 換源
      • 1. 備份
      • 2. 刪除或注釋sources.list中的所有內容,將下面的內容復制進去
      • 3. 保存
    • 查看一些信息
      • 1.查看cuda的版本
      • 2.查看cudnn的版本
      • 3.查看opencv的版本
      • 4.查看TensorRT的版本
      • 5.查看系統版本
      • 6.查看正在運行的進程
    • 一些軟件的安裝
      • 1.安裝todesk遠程軟件
      • 2.裝jtop查詢系統工具
    • 修改默認python、pip版本
      • 1. 修改python版本
      • 2.修改pip版本
    • 一些軟件的安裝
      • 1. torch & torchvision的安裝
      • 2.archiconda的安裝
      • 3.TensorRT的安裝
      • 4.安裝中文輸入法
      • 5.安裝ROS
        • 1.更換源
        • 2.設置最新的密鑰
        • 3、安裝:
        • 4、初始化ROS
        • 5、安裝rosinstall
        • 6、添加ros環境變量
        • 7、測試
      • 6. 安裝pycharm
        • 1. 下載Pycharm
        • 2.解決這個問題的方法:
      • 7.安裝DeepStream
    • 部署yolov5(使用TensorRT)
      • TensorRT加速
    • 安裝pycharm
      • 1. 下載Pycharm
      • 2.解決這個問題的方法:

準備

  • 數據線、鍵盤、鼠標、顯示器少不掉(顯示器要支持HDMI接口,我看網上說HDMI轉VGA的會黑屏,沒有試過)
  • Ubuntu16或Ubuntu18的虛擬機,或電腦作為主機(Ubuntu20.04不行,因為我電腦就是,第一次裝了沒法用)
  • 有網的環境,而且網速一定要好,我在實驗室里網速一般,經常下載失敗
  • 使用SDKmanager刷機

  • 打開準備的Ubuntu系統作為主機
    注意 如果使用虛擬機需要分配較大的硬盤空間,起碼得40GB,最好能有100G這個樣子,否則空間不足也會失敗
  • 注冊英偉達開發者賬號https://developer.nvidia.com/
  • 下載英偉達的SDKmanager(地址百度一下吧),安裝,打開,登錄
  • TX2板子的第三根引腳和GND相連(進入恢復模式),上電,連主機
  • Host Machine有的博客里面也點了,實際上不需要的,這個是給你電腦主機安裝cuda之類的,如果沒有這個需要,就不用勾上
    可以輸入lsusb 看看有沒有英偉達的設備,確保板子連上
    7. 底下的第一個I accept…要勾上,第二個Downloader now and install later第一次也建議勾上,意思是先下載,不安裝。待會下載完了可以一起安裝。如果是邊下載變安裝,網速不好很容易出問題
  • 先會燒寫jetson os(就是魔改過的Ubuntu18),燒寫到要結束的時候,顯示屏會自己亮起來,過一段時間會出現這樣的提示

    不慌,這個是鏡像已經燒寫好了,可以進入系統了,后面是安裝SDK軟件的部分。我們先登錄系統,設置用戶和密碼
    之后在TX2上設置開啟SSH服務
  • ps -e | grep ssh # 查看有沒有SSH服務 sudo apt-get install openssh-server sudo apt-get install openssh-client service ssh start # 開啟服務

    如果ps -e | grep ssh當中有sshd則表示正常
    可以通過ifconfig或者 ip addr查看ip地址
    在主機上輸入賬號和密碼一般就可以連接了

    確保主機和TX2在同一個局域網絡下
    我的虛擬機配置如下,建議使用橋接模式而不是NAT模式

    然后耐心等待他自己安裝,有可能不能成功,多試幾次

    我在最后一步的Deepstream出錯了,查看日志,認為是內存不夠的問題,這個SDK暫時不是很重要,后面自己裝一下
    在使用SDKmanager中有問題可以參考官方的說明
    我遇到的問題:
    1、Default ip is not avaliable. Please make sure the default ip is shown in ip addr, or use a customer ip instead.
    ip默認是192.168.55.1,我第一次刷機是直接可以連上的,第二次就報了這個錯誤,我換了一個ip192.168.3.141就可以了
    2、flash 1%的時候就會error, 提示板子狀態不對,不在恢復模式之類的話(我確定是在恢復模式),多試幾次,可能試一次就好了,也有可能試很多很多次(啥也沒動,不知道為什么,玄學)

    手動安裝SDK

    雖然英偉達提供的工具傻瓜式操作,十分好用(也不好用,十分容易出錯),但實際難免會遇到正常刷機不了的。英偉達提供了其他的安裝方法https://docs.nvidia.com/jetson/jetpack/install-jetpack/index.html
    刷完機是裸系統的話,可以讓板子在線安裝(我沒試過)

    我第一次也沒有安裝成功,自己手動安裝了cuda,cudnn,pytorch,tersonRT等。后面可能會介紹一些安裝的方法。

    SSD啟動

    我們TX2的板子上裝了一塊128GB的固態硬盤,十分實用,下面介紹如何將SSD設為第一啟動項

    1. 格式化已安裝的 SSD

    打開DISK

    點右上角的三條橫線按鈕

    之后Fromat
    點底下的加號

    留16GB的交換空間

    之后create,就成功創建卷

    2. 從SD卡復制到SSD

    git clone https://github.com/jetsonhacks/rootOnNVMe.git cd rootOnNVMe ./copy-rootfs-ssd.sh

    如果執行了這個腳本卻沒有反映,一般是權限不夠,給它權限就好了,就像這樣

    chmod +x copy-rootfs-ssd.sh

    3. 啟用從 SSD 啟動

    ./setup-service.sh

    之后重新啟動,就可以看到TX2的內存有100多G了

    換源

    TX2的軟件源為國外服務器,網速會很慢,需要換國內的ARM源(記得是ARM的)

    1. 備份

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #先備份原文件sources.list sudo vim /etc/apt/sources.list #sudo打開sources.list

    2. 刪除或注釋sources.list中的所有內容,將下面的內容復制進去

    清華源

    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted

    科大源:

    deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse deb htp://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main universe restricted deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main universe restricted

    3. 保存

    sudo apt-get update sudo apt-get upgrade

    查看一些信息

    1.查看cuda的版本

    nvcc -V # 或者nvcc --version

    2.查看cudnn的版本

    網上的那些一般輸進去沒有反應,仔細考慮過覺得這樣才是正確的

    cat /usr/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

    3.查看opencv的版本

    pkg-config --modversion opencv

    一開始不能查看opencv版本,原因是由于沒有找到opencv.pc,而jetpack4.4+刷機刷的opencv是opencv4
    將/usr/lib/aarch64-linux-gnu/pkgconfig中的opencv4.pc,復制到/usr/lib/pkgconfig下,并改名為opencv.pc就可以了。

    cd /usr/lib/aarch64-linux-gnu/pkgconfig sudo cp opencv4.pc /usr/lib/pkgconfig/opencv.pc

    默認是4.1.1

    4.查看TensorRT的版本

    dpkg -l | grep TensorRT

    5.查看系統版本

    cat /etc/lsb-release

    6.查看正在運行的進程

    top

    一些軟件的安裝

    1.安裝todesk遠程軟件

    sudo dpkg -i todesk_x.x.x_aarch64.deb

    2.裝jtop查詢系統工具

    sudo -H python3 -m pip install jetson-stats

    修改默認python、pip版本

    1. 修改python版本

    默認板子刷機后是自帶python為2.7和python3.6.9解析器的(使用python3 -V可以查到),但默認是python2.7 ,如果需要python3.6.9,需使用下面命令調用python3.6版本

    sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150 sudo update-alternatives --config python

    2.修改pip版本

    sudo apt-get install python3-pip

    一些軟件的安裝

    1. torch & torchvision的安裝

    此處參考官方教程 里面內容十分詳盡
    本人是下載使用了官方提供的torch-1.8.0-cp36-cp36m-linux_aarch64.whl包

    sudo apt-get install python3-pip libopenblas-base libopenmpi-dev pip3 install Cython pip3 install numpy torch-1.8.0-cp36-cp36m-linux_aarch64.whl #注意路徑下包含剛才下載的“torch-1.8.0”這個包

    pytorch應該就被安裝好了,安裝torchvision的話要注意對應pytorch的版本!

    sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev git clone --branch v0.9.0 https://github.com/pytorch/vision # 從github上下載對應版本的 python3 setup.py install --user # 在下載下來的文件夾下運行安裝程序,編譯過程會比較慢,耐心等一下

    我遇到的問題:
    報這樣的錯誤:

    virtual AVCodec* findCodec(AVCodecParameters* params); ^~~~~~~~~~~~~~~~~ /home/paluhin/Downloads/torchvision/torchvision/csrc/io/video_reader/…/decoder/stream.h:52:20: error: expected ‘;’ at end of member declaration virtual AVCodec* findCodec(AVCodecParameters* params); ^~~~~~~~~ /home/paluhin/Downloads/torchvision/torchvision/csrc/io/video_reader/…/decoder/stream.h:52:47: error: expected ‘)’ before ‘’ token virtual AVCodec findCodec(AVCodecParameters* params); ^

    網上找來找去也沒有人提到,最后在論壇找到了方法,希望以后遇到這個問題的人不會像我一樣煎熬

    sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev # 不行的話試一下 $ sudo mv /usr/bin/ffmpeg /usr/bin/ffmpeg_backup

    2.archiconda的安裝

    本人現在是不使用conda的,但之前裝過,記錄一下
    TX2無法使用anaconda,有大佬編譯了archiconda,這東西就是anaconda的aarch64的版本。我用這個進行虛擬環境的安裝。
    直接到https://github.com/Archiconda/build-tools/releases下載.sh文件
    然后到你下載文件的地址
    sh 你的sh文件

    ./Archiconda3-0.2.3-Linux-aarch64.sh

    之后點yes,安裝完畢。安裝中間有叫你選擇目錄,如果不喜歡它默認的可以換。
    archiconda的使用和普通的anaconda沒有什么區別
    如果你在虛擬環境里面使用pytorch,請務必建立python3.6的環境

    conda create -n pytorch python=3.6 conda activate pytorch

    3.TensorRT的安裝

    刷機過后會自帶TensorRT,下面記錄自己之前自行安裝的方法。僅記錄自己用tar安裝tensorRT的流程,對于DEV版本等的安裝,請移步其他博客。
    參看cuda,cudnn的版本后挑選TensorRT版本(千萬不要不符合,不然很麻煩,可能我當時第一次選的不對報了一些奇怪的錯誤,換了版本就好了)
    下面的指令是copy其他博主的

    # 在home下將下載的壓縮文件進行解壓 tar xzvf TensorRT-6.0.1.5.Ubuntu-16.04.x86_64-gnu.cuda-10.1.cudnn7.6.tar.gz# 解壓得到TensorRT-6.0.1.5的文件夾,將里邊的lib絕對路徑添加到環境變量中 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/xxxxx/TensorRT-6.0.1.5/lib # 如果手動添加到.bashrc文件中,需要執行source .bashrc命令,配好的環境才能生效# 安裝TensorRT cd TensorRT-6.0.1.5/python pip install tensorrt-6.0.1.5-cp37-none-linux_x86_64.whl # 博主親測,這里你的python環境并沒有限制,py35,py36,py37都可# 安裝UFF,支持tensorflow模型轉化 cd TensorRT-6.0.1.5/uff pip install uff-0.6.5-py2.py3-none-any.whl# 安裝graphsurgeon,支持自定義結構 cd TensorRT-6.0.1.5/graphsurgeon pip install graphsurgeon-0.4.1-py2.py3-none-any.whl

    4.安裝中文輸入法

    sudo apt install fcitx fcitx-googlepinyin fcitx-table-wbpy fcitx-pinyin fcitx-sunpinyin

    在語言設置選項里(langugae support)選擇fcitx。
    重啟電腦,在Fcitx configuration里配置下就好了。

    5.安裝ROS

    1.更換源

    我用的是自帶的源

    sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

    如果需要換源的話可以參考這一篇

    2.設置最新的密鑰

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

    3、安裝:

    sudo apt-get update sudo apt-get install ros-melodic-desktop-full sudo apt-get install ros-melodic-rqt*

    4、初始化ROS

    sudo apt install python-rosdep sudo rosdep init rosdep update

    如果出現下面情況,基本是網絡問題,換個網絡嘗試下

    ubuntu@ubuntu-d:~$ sudo rosdep init ERROR: cannot download default sources list from: https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list Website may be down.

    或修改hosts Ubuntu直接在終端輸入

    sudo gedit /etc/hosts

    添加以下內容保存即可

    151.101.84.133 raw.githubusercontent.com

    這個解決方法來自這里
    如果不行試試這個
    或者這個
    其實我后來依舊出問題

    rosdep update reading in sources list data from /etc/ros/rosdep/sources.list.d ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:<urlopen error timed out> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml) ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml]:<urlopen error [Errno 104] Connection reset by peer> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml) ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml]:<urlopen error [Errno 104] Connection reset by peer> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml) ^CTraceback (most recent call last):File "/usr/bin/rosdep", line 11, in <module>load_entry_point('rosdep==0.21.0', 'console_scripts', 'rosdep')()File "/usr/lib/python2.7/dist-packages/rosdep2/main.py", line 146, in rosdep_mainexit_code = _rosdep_main(args)File "/usr/lib/python2.7/dist-packages/rosdep2/main.py", line 441, in _rosdep_mainreturn _no_args_handler(command, parser, options, args)File "/usr/lib/python2.7/dist-packages/rosdep2/main.py", line 450, in _no_args_handlerreturn command_handlers[command](options)File "/usr/lib/python2.7/dist-packages/rosdep2/main.py", line 662, in command_updateros_distro=options.ros_distro)File "/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py", line 480, in update_sources_listrosdep_data = download_rosdep_data(source.url)File "/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py", line 315, in download_rosdep_dataf = urlopen(url_request, timeout=DOWNLOAD_TIMEOUT)File "/usr/lib/python2.7/urllib2.py", line 154, in urlopenreturn opener.open(url, data, timeout)File "/usr/lib/python2.7/urllib2.py", line 429, in openresponse = self._open(req, data)File "/usr/lib/python2.7/urllib2.py", line 447, in _open'_open', req)File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chainresult = func(*args)File "/usr/lib/python2.7/urllib2.py", line 1248, in https_opencontext=self._context)File "/usr/lib/python2.7/urllib2.py", line 1202, in do_openh.request(req.get_method(), req.get_selector(), req.data, headers)File "/usr/lib/python2.7/httplib.py", line 1099, in requestself._send_request(method, url, body, headers)File "/usr/lib/python2.7/httplib.py", line 1139, in _send_requestself.endheaders(body)File "/usr/lib/python2.7/httplib.py", line 1095, in endheadersself._send_output(message_body)File "/usr/lib/python2.7/httplib.py", line 898, in _send_outputself.send(msg)File "/usr/lib/python2.7/httplib.py", line 860, in sendself.connect()File "/usr/lib/python2.7/httplib.py", line 1312, in connectHTTPConnection.connect(self)File "/usr/lib/python2.7/httplib.py", line 837, in connectself.timeout, self.source_address)File "/usr/lib/python2.7/socket.py", line 566, in create_connectionsock.connect(sa)File "/usr/lib/python2.7/socket.py", line 228, in methreturn getattr(self._sock,name)(*args) KeyboardInterrupt

    沒辦法,買代理吧
    如果出現下面情況,是python版本問題,換到python2就可以了
    home/rm/.local/lib/python3.6/site-packages/pkg_resources/init.py:119:

    PkgResourcesDeprecationWarning: 0.18ubuntu0.18.04.1 is an invalid version and will not be supported in a future releasePkgResourcesDeprecationWarning, Traceback (most recent call last):File "/usr/bin/rosdep", line 6, in <module>from pkg_resources import load_entry_pointFile "/home/rm/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3266, in <module>@_call_asideFile "/home/rm/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3241, in _call_asidef(*args, **kwargs)File "/home/rm/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3279, in _initialize_master_working_setworking_set = WorkingSet._build_master()File "/home/rm/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 573, in _build_masterws.require(__requires__)File "/home/rm/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 891, in requireneeded = self.resolve(parse_requirements(requirements))File "/home/rm/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 777, in resolveraise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'rosdep==0.21.0' distribution was not found and is required by the application

    解決:

    sudo update-alternatives --config python 有 2 個候選項可用于替換 python (提供 /usr/bin/python)。選擇 路徑 優先級 狀態 ------------------------------------------------------------ * 0 /usr/bin/python3 150 自動模式1 /usr/bin/python2 100 手動模式2 /usr/bin/python3 150 手動模式要維持當前值[*]請按<回車鍵>,或者鍵入選擇的編號:1 update-alternatives: 使用 /usr/bin/python2 來在手動模式中提供 /usr/bin/python (python)

    重新進行初始化等步驟又可以了

    sudo rosdep init Wrote /etc/ros/rosdep/sources.list.d/20-default.list Recommended: please runrosdep update

    5、安裝rosinstall

    sudo apt-get install python-rosinstall

    6、添加ros環境變量

    echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc

    完成了

    7、測試

    可以嘗試分別在三個終端下執行這三條命令

    roscore rosrun turtlesim turtlesim_node rosrun turtlesim turtle_teleop_key

    成功的話,可以方向鍵操作小海龜,則ROS成功安裝。

    6. 安裝pycharm

    1. 下載Pycharm

    (1)下載pycharm社區版,下載地址
    (2)解壓下載文件到任意位置待用。可以使用tar -xf來進行解壓。
    (3)cd到bin文件夾,運行./pycharm.sh,出現以下報錯。問題是缺少JDK環境。

    Gtk-Message: 18:05:39.195: GtkDialog mapped without a transient parent. This is discouraged.

    2.解決這個問題的方法:

    (1)輸入以下指令:(jetpack為4.5.1版本)

    apt-cache search openjdk sudo apt-get install openjdk-11-jdk

    (2)等待完成后用下面指令檢查版本情況

    java -version // 查看安裝結果 penjdk version "11.0.13" 2021-10-19 OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.18.04) OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.18.04, mixed mode)

    (3)沒問題后進行環境變量配置
    首先切換用戶到root

    sudo -i gedit ~/.bashrc

    在末尾加入

    export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH source ~/.bashrc

    (4)運行Pycharm
    進入剛剛解壓的pycharm/bin文件夾運行./pycharm.sh

    7.安裝DeepStream

    Deepstream的安裝可以參考官方教程
    https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Quickstart.html#jetson-setup
    先安裝依賴

    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 the DeepStream SDK一欄
    我選擇了Method 2的方法,原文如下:

    Method 2: Using the DeepStream tar package: https://developer.nvidia.com/deepstream_sdk_v6.0.0_jetsontbz2
    Download the DeepStream 6.0 Jetson tar package deepstream_sdk_v6.0.0_jetson.tbz2 to the Jetson device.
    Enter the following commands to extract and install the DeepStream SDK:

    $ sudo tar -xvf deepstream_sdk_v6.0.0_jetson.tbz2 -C / $ cd /opt/nvidia/deepstream/deepstream-6.0 $ sudo ./install.sh $ sudo ldconfig

    我其實用的是v5.1.0 版本,下的是deepstream_sdk_v5.1.0_jetson.tbz2,操作是一樣的
    安裝完成進入官方例程文件夾

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

    部署yolov5(使用TensorRT)

    到github上去下載源碼

    git clone https://github.com/ultralytics/yolov5.git

    在yolov5項目下,右鍵打開終端,安裝依賴
    我們已經安裝好了pytorch,torchvision,建議把這兩個注釋掉,以防命令行自動更新了

    pip3 install -r requirements -i https://mirror.baidu.com/pypi/sample

    下載yolov5的權重,我用的是之前我自己訓練好的,需要改名為yolov5s.pt(不改名字就改代碼)

    TensorRT加速

    git clone https://github.com/wang-xinyu/tensorrtx.git

    具體編譯方法原作者有很詳細的說明

    cd tensorrtx cp yolov5/gen_wts.py ~/yolov5 cd ~/yolov5 python gen_wts.py -w yolov5s.pt -o yolov5s.wts

    就得到了wts格式的文件

    # 需要改一下CLASS NUM的值 cd ~/tensorrtx/yolov5 mkdir build && cd build mv ~/yolov5/yolov5s.wts ./ cmake .. make -j

    等出現這個就好了

    [ 60%] Building CXX object CMakeFiles/yolov5.dir/calibrator.cpp.o [ 80%] Building CXX object CMakeFiles/yolov5.dir/yolov5.cpp.o [100%] Linking CXX executable yolov5 [100%] Built target yolov5

    表示編譯成功

    ./yolov5 -s yolov5s.wts yolov5s.engine s #生成engine文件需要一段時間

    等出現這個就好了

    Loading weights: yolov5s.wts Building engine, please wait for a while... Build engine successfully!

    有了engine就可以調用了
    測試一下

    ./yolov5 -d yolov5s.engine ../samples

    samples下面放需要測試的圖片

    6ms 6ms

    會出現推理所用的時間,在build下面會出現推理后的結果
    我遇到的問題
    1、

    [12/24/2021-11:36:38] [E] [TRT] Parameter check failed at: ../builder/Network.cpp::addScale::482, condition: shift.count > 0 ? (shift.values != nullptr) : (shift.values == nullptr) yolov5: /home/rm/tensorrtx/yolov5/common.hpp:155: nvinfer1::IScaleLayer* addBatchNorm2d(nvinfer1::INetworkDefinition*, std::map<std::__cxx11::basic_string<char>, nvinfer1::Weights>&, nvinfer1::ITensor&, std::__cxx11::string, float): Assertion `scale_1' failed. Aborted (core dumped)

    不知道為什么,重新下載編譯了一遍工程就好了,可能文件缺失了吧,又是玄學
    2、
    編譯核心時出現問題

    Loading weights: yolov5s.wts [01/20/2022-18:08:29] [E] [TRT] (Unnamed Layer* 214) [Convolution]: kernel weights has count 3840 but 32640 was expected [01/20/2022-18:08:29] [E] [TRT] (Unnamed Layer* 214) [Convolution]: count of 3840 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 255 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 255 / 1 = 32640 [01/20/2022-18:08:29] [E] [TRT] (Unnamed Layer* 214) [Convolution]: kernel weights has count 3840 but 32640 was expected [01/20/2022-18:08:29] [E] [TRT] (Unnamed Layer* 214) [Convolution]: count of 3840 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 255 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 255 / 1 = 32640 [01/20/2022-18:08:29] [E] [TRT] (Unnamed Layer* 214) [Convolution]: kernel weights has count 3840 but 32640 was expected [01/20/2022-18:08:29] [E] [TRT] (Unnamed Layer* 214) [Convolution]: count of 3840 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 255 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 255 / 1 = 32640 [01/20/2022-18:08:29] [E] [TRT] (Unnamed Layer* 214) [Convolution]: kernel weights has count 3840 but 32640 was expected [01/20/2022-18:08:29] [E] [TRT] (Unnamed Layer* 214) [Convolution]: count of 3840 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 255 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 255 / 1 = 32640 Building engine, please wait for a while... [01/20/2022-18:08:29] [E] [TRT] (Unnamed Layer* 214) [Convolution]: kernel weights has count 3840 but 32640 was expected [01/20/2022-18:08:29] [E] [TRT] (Unnamed Layer* 214) [Convolution]: count of 3840 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 255 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 255 / 1 = 32640 [01/20/2022-18:08:29] [E] [TRT] Could not compute dimensions for (Unnamed Layer* 214) [Convolution]_output, because the network is not valid. [01/20/2022-18:08:29] [E] [TRT] Network validation failed. Build engine successfully! yolov5: /home/ubuntu/tensorrtx-yolov5-RM/yolov5/yolov5.cpp:245: void APIToModel(unsigned int, nvinfer1::IHostMemory**, bool&, float&, float&, std::string&): Assertion `engine != nullptr' failed. 已放棄 (核心已轉儲)

    CALSS_NUM沒有改
    未完待續。。

    安裝pycharm

    1. 下載Pycharm

    (1)下載pycharm社區版,下載地址
    (2)解壓下載文件到任意位置待用。可以使用tar -xf來進行解壓。
    (3)cd到bin文件夾,運行./pycharm.sh,出現以下報錯。問題是缺少JDK環境。

    Gtk-Message: 18:05:39.195: GtkDialog mapped without a transient parent. This is discouraged.

    2.解決這個問題的方法:

    (1)輸入以下指令:(jetpack為4.5.1版本)

    apt-cache search openjdk sudo apt-get install openjdk-11-jdk

    (2)等待完成后用下面指令檢查版本情況

    java -version // 查看安裝結果 penjdk version "11.0.13" 2021-10-19 OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.18.04) OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.18.04, mixed mode)

    (3)沒問題后進行環境變量配置
    首先切換用戶到root

    sudo -i gedit ~/.bashrc

    在末尾加入

    export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH source ~/.bashrc

    (4)運行Pycharm
    進入剛剛解壓的pycharm/bin文件夾運行./pycharm.sh

    總結

    以上是生活随笔為你收集整理的TX2刷机和软件安装过程记录的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。