在NVIDIA Jetson Xavier NX上安装llvm和numba,以及在Jetxon NX上跑通CenterTrack的目标跟踪模型

1 我的安装环境如下:

1、查看Jetson的相关版本信息

jetson_release -v

zhihui@zhihui-desktop:~$ jetson_release -v
 - NVIDIA Jetson Xavier NX (Developer Kit Version)
   * Jetpack UNKNOWN [L4T 32.4.4]
   * NV Power Mode: MODE_15W_6CORE - Type: 2
   * jetson_stats.service: active
 - Board info:
   * Type: Xavier NX (Developer Kit Version)
   * SOC Family: tegra194 - ID:25
   * Module: P3668 - Board: P3509-000
   * Code Name: jakku
   * CUDA GPU architecture (ARCH_BIN): 7.2
   * Serial Number: 1422420034718
 - Libraries:
   * CUDA: 10.2.89
   * cuDNN: 8.0.0.180
   * TensorRT: 7.1.3.0
   * Visionworks: 1.6.0.501
   * OpenCV: 4.1.1 compiled CUDA: NO
   * VPI: 0.4.4
   * Vulkan: 1.2.70
 - jetson-stats:
   * Version 3.0.1
   * Works on Python 3.6.9
zhihui@zhihui-desktop:~$ 

2、也可以使用jtop命令查看

在这里插入图片描述

3、torch的相关版本(这个是在Jetson NX设备上的)

  • torch 1.6.0
  • torchvision 0.7.0a0+78ed10c

4、我在服务器测试的CenterTrack环境如下:

  • cuda 10.2
  • cudnn 7.6.5
  • torch 1.4.0
  • torchvision 0.5.0

2 安装llvmlite

2.1 安装llvm

在安装llvmlite之前要先安装llvm

LLVM官网:https://releases.llvm.org/

下面是LLVM的安装流程

1、建议安装9.0.0或10.0.0版本Pre-Built Binaries版本:选择AArch64-Linux版本(arm架构)下载即可,

在这里插入图片描述

  • llvm9.0.0下载:

wget https://releases.llvm.org/9.0.0/clang+llvm-9.0.0-aarch64-linux-gnu.tar.xz

  • llvm10.0.0下载

wget https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-aarch64-linux-gnu.tar.xz

2、解压压缩包

tar xJvf clang+llvm-10.0.0-aarch64-linux-gnu.tar.xz

3、修改环境变量

vim ~/.bashrc

4、把如下的环境变量PATH添加到~/.bashrc文件中

export PATH=$PATH:/home/nano/clang+llvm-10.0.0-aarch64-linux-gnu/bin

因为是编译好的库包,因此直接添加到环境变量中就可以使用!

5、环境变量生效

source ~/.bashrc

6、测试安装的llvm是否安装成功

clang++ -v # 返回如下信息表示安装成功

zhihui@zhihui-desktop:~$ clang++ -v
clang version 10.0.0 (http://git.linaro.org/toolchain/jenkins-scripts.git 271be43175ac464ec52b009ab70d952167512aef)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/zhihui/shl/clang+llvm-10.0.0-aarch64-linux-gnu/bin
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/aarch64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda-10.2, version 10.1
zhihui@zhihui-desktop:~$ 

2.2 安装llvmlite

安装llvlite之气,首先要查看一下你要安装的llvmlite的版本和llvm版本,因为他们之间有着对应关系,如下是llvmlite提在pypi上提供的对应关系

在这里插入图片描述

2.2.1 使用pip安装llvmlite

1、使用pip即可安装llvmlite

pip install llvmlite==0.34.0

如果你安装报错,继续往下看!

2.2.2 pip安装llvmlite报错:/usr/bin/ld: cannot find -ltinfo

如下是我在用pip安装llvmlite的时候报错信息如下:

zhihui@zhihui-desktop:~/shl/clang+llvm-9.0.0-aarch64-linux-gnu/bin$ pip install llvmlite==0.34.0
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting llvmlite==0.34.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/0b/96/07bfa93a103fb9e3e9ae7f9f7c6687ae714aee66b6f3000da3fad71e0aa2/llvmlite-0.34.0.tar.gz (107 kB)
Building wheels for collected packages: llvmlite
  Building wheel for llvmlite (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-x97lw89z/llvmlite/setup.py'"'"'; __file__='"'"'/tmp/pip-install-x97lw89z/llvmlite/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-d39gbtll
       cwd: /tmp/pip-install-x97lw89z/llvmlite/
  Complete output (23 lines):
  running bdist_wheel
  /usr/bin/python3 /tmp/pip-install-x97lw89z/llvmlite/ffi/build.py

......
lLLVMAArch64Info -lLLVMSupport -lLLVMDemangle -lz -lrt -ldl -ltinfo -lpthread -lm
    /usr/bin/ld: cannot find -ltinfo
    collect2: error: ld returned 1 exit status
    Makefile.linux:20: recipe for target 'libllvmlite.so' failed
    make: *** [libllvmlite.so] Error 1
    9.0.0
    
    SVML not detected
    Traceback (most recent call last):
      File "/tmp/pip-install-e3p8ncuv/llvmlite/ffi/build.py", line 191, in <module>
        main()
      File "/tmp/pip-install-e3p8ncuv/llvmlite/ffi/build.py", line 181, in main
        main_posix('linux', '.so')
      File "/tmp/pip-install-e3p8ncuv/llvmlite/ffi/build.py", line 173, in main_posix
        subprocess.check_call(['make', '-f', makefile])
      File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['make', '-f', 'Makefile.linux']' returned non-zero exit status 2.
    error: command '/usr/bin/python3' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-e3p8ncuv/llvmlite/setup.py'"'"'; __file__='"'"'/tmp/pip-install-e3p8ncuv/llvmlite/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-dlz3z5md/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/zhihui/.local/include/python3.6m/llvmlite Check the logs for full command output.
zhihui@zhihui-desktop:~/shl/clang+llvm-9.0.0-aarch64-linux-gnu/bin$ ^Ct

我们来先看一下错误问题,从下图可以看到错误主要要两条:

  • 1)/usr/bin/ld: cannot find -ltinfo
  • 2)Makefile.linux:20: recipe for target 'libllvmlite.so' failed

我一开始就是先按照第二条错误找解决方法,但是几乎没有什么有用信息,有些和我的情况也不符合,最终也没有解决问题!
在这里插入图片描述

后面我就开始按照第一条错误找解决方法,发现是由于缺少了库文件tinfo(关于查看缺少的是什么文件参考这篇博客

1、查找有没有相关的tinfo库文件

zhihui@zhihui-desktop:~/shl/clang+llvm-9.0.0-aarch64-linux-gnu/bin$ apt-cache search libtinfo
libtinfo-dev - developer's library for the low-level terminfo library
libtinfo5 - shared low-level terminfo library for terminal handling
libtinfo5-dbg - debugging/profiling library for the low-level terminfo library

2、查找到tinfo的库文件libtinfo-dev,然后安装

sudo apt-get install libtinfo-dev

zhihui@zhihui-desktop:~/shl/clang+llvm-9.0.0-aarch64-linux-gnu/bin$ sudo apt-get install libtinfo-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  activity-log-manager archdetect-deb bamfdaemon bogl-bterm busybox-static compiz-core compiz-plugins-default
  cryptsetup-bin debhelper dh-autoreconf dh-strip-nondeterminism dpkg-repack gir1.2-accounts-1.0 gir1.2-gdata-0.0
  gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gir1.2-harfbuzz-0.0 gir1.2-rb-3.0 gir1.2-signon-1.0
  gir1.2-timezonemap-1.0 gir1.2-totem-1.0 gir1.2-totemplparser-1.0 gir1.2-xkl-1.0 gnome-calculator gnome-system-monitor
  grub-common gtk3-nocsd icu-devtools kde-window-manager kpackagetool5 kwayland-data kwin-common kwin-x11
  libarchive-cpio-perl libatkmm-1.6-1v5 libboost-python1.65.1 libcairomm-1.0-1v5 libcolumbus1-common libcolumbus1v5
  libcompizconfig0 libdebian-installer4 libdecoration0 libdmapsharing-3.0-2 libegl1-mesa-dev libeigen3-dev
  libfile-stripnondeterminism-perl libgeonames-common libgeonames0 libgles2-mesa-dev libglibmm-2.4-1v5 libgpod-common
  libgpod4 libgraphite2-dev libgtk3-nocsd0 libgtkmm-3.0-1v5 libharfbuzz-gobject0 libicu-le-hb0 libiculx60
  libkdecorations2-5v5 libkdecorations2private5v5 libkf5activities5 libkf5declarative-data libkf5declarative5
  libkf5globalaccelprivate5 libkf5idletime5 libkf5kcmutils-data libkf5kcmutils5 libkf5package-data libkf5package5
  libkf5plasma5 libkf5quickaddons5 libkf5waylandclient5 libkf5waylandserver5 libkscreenlocker5 libkwin4-effect-builtins1
  libkwineffects11 libkwinglutils11 libkwinxrenderutils11 libmail-sendmail-perl libnm-gtk0 liborc-0.4-dev
  liborc-0.4-dev-bin libpanel-applet3 libpangomm-1.4-1v5 libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libpinyin-data
  libpinyin13 libqt5designer5 libqt5help5 libqt5positioning5 libqt5sensors5 libqt5sql5 libqt5test5 libqt5webchannel5
  libqt5webkit5 libsgutils2-2 libsignon-glib1 libsys-hostname-long-perl libtimezonemap-data libtimezonemap1
  libunity-control-center1 libunity-core-6.0-9 libunity-misc4 libwayland-bin libwayland-dev libxcb-composite0
  libxcb-cursor0 libxcb-damage0 libxrandr-dev libxrender-dev libzeitgeist-1.0-1 os-prober pkg-config po-debconf
  qml-module-org-kde-kquickcontrolsaddons rdate session-shortcuts tasksel tasksel-data unity-asset-pool unity-greeter
  unity-lens-applications unity-lens-files unity-lens-music unity-lens-video unity-schemas unity-scope-video-remote
  unity-scopes-master-default unity-scopes-runner x11proto-randr-dev
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  libtinfo-dev
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 74.2 kB of archives.
After this operation, 360 kB of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libtinfo-dev arm64 6.1-1ubuntu1.18.04 [74.2 kB]
Fetched 74.2 kB in 2s (45.2 kB/s)       
Selecting previously unselected package libtinfo-dev:arm64.
(Reading database ... 164346 files and directories currently installed.)
Preparing to unpack .../libtinfo-dev_6.1-1ubuntu1.18.04_arm64.deb ...
Unpacking libtinfo-dev:arm64 (6.1-1ubuntu1.18.04) ...
Setting up libtinfo-dev:arm64 (6.1-1ubuntu1.18.04) ...

3、在安装llvmlite就没有问题了

pip install llvmlite==0.33.0

zhihui@zhihui-desktop:~/shl/clang+llvm-9.0.0-aarch64-linux-gnu/bin$ pip install llvmlite==0.33.0
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting llvmlite==0.33.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/71/4e/b1086722f4fa0b52cf8c0d4b2c985fb3f95d2f1be1b010259497b2464c1d/llvmlite-0.33.0.tar.gz (104 kB)
Building wheels for collected packages: llvmlite
  Building wheel for llvmlite (setup.py) ... done
  Created wheel for llvmlite: filename=llvmlite-0.33.0-cp36-cp36m-linux_aarch64.whl size=18340330 sha256=1311e2f739409b98058c31c6224c1d6cc1b84029c24adee46fefbc10c71309fd
  Stored in directory: /home/zhihui/.cache/pip/wheels/e3/75/d7/0c4099140cbaac772fc57aed71df74e650660d1f206e6ffbc7
Successfully built llvmlite
Installing collected packages: llvmlite
Successfully installed llvmlite-0.33.0
zhihui@zhihui-desktop:~/shl/clang+llvm-9.0.0-aarch64-linux-gnu/bin$ 

3 开始安装numba

numba可以基于llvm动态生成优化代码提高python的执行效率,使用很方便,只需要给python代码加上修饰器就好了。由于numba依赖llvm,因此需要事先安装好llvm。

3.1 使用pip安装numba

直接使用pip安装numba就可以

pip install numba

如果你安装过程中报错,请继续看下文!

3.2 安装numba报错:error "TBB version is too old, 2019 update 5,

然后开始安装numba的时候又报错误:#error "TBB version is too old, 2019 update 5, i.e. TBB_INTERFACE_VERSION >= 11005 required",意思就是说TBB的版本太低,但是谁能够告诉我TBB是个什么东西???,具体报错信息如下:

numba/np/ufunc/tbbpool.cpp:30:2: error: #error "TBB version is too old, 2019 update 5, i.e. TBB_INTERFACE_VERSION >= 11005 required"
#error "TBB version is too old, 2019 update 5, i.e. TBB_INTERFACE_VERSION >= 11005 required"

在这里插入图片描述

后面经过查询,TTBThreading Building Blocks的缩写,就是关于线程的一个模块,而我们安装的numba是依赖这个模块的,因此需要先把这个TTB版本过低的问题解决!(参考

安装比较新的TTB版本:

git clone https://github.com/wjakob/tbb.git
cd tbb/build
cmake ..
make -j
sudo make install

也有说用apt的方式安装tbb的我不知道是不是同一个东西,也不知道行不行,没有尝试,如果要试自己尝试:

sudo apt install libtbb-dev

这里可以查看TBB的版本更细迭代的信息:

安装编译好之后,再安装numba,可以成功安装numba,奈斯!!!

zhihui@zhihui-desktop:~/shl/tbb/build$ pip install numba
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting numba
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5e/81/6fd1dd064bcf71a79da109e8966a39e2da61d68bf0bd1e0839fa997f8c41/numba-0.51.2.tar.gz (2.1 MB)
     |████████████████████████████████| 2.1 MB 708 kB/s 
Requirement already satisfied: llvmlite<0.35,>=0.34.0.dev0 in /home/zhihui/.local/lib/python3.6/site-packages (from numba) (0.34.0)
Requirement already satisfied: numpy>=1.15 in /usr/local/lib/python3.6/dist-packages (from numba) (1.16.1)
Requirement already satisfied: setuptools in /home/zhihui/.local/lib/python3.6/site-packages (from numba) (50.3.2)
Building wheels for collected packages: numba
  Building wheel for numba (setup.py) ... done
  Created wheel for numba: filename=numba-0.51.2-cp36-cp36m-linux_aarch64.whl size=2975288 sha256=494f4df1ba36fe4eb209827bead47b0910e35702eba0c39e5d83c8d0eb046e2b
  Stored in directory: /home/zhihui/.cache/pip/wheels/cc/7a/97/f45c63a61c0d48218e1f0091cac2adf05d5ff6ec5803cbc6ac
Successfully built numba
Installing collected packages: numba
Successfully installed numba-0.51.2
zhihui@zhihui-desktop:~/shl/tbb/build$ 

4 Jetson NX安装sklearn一直停止等待

安装sklearn的时候,会一直停滞在Building wheel for scikit-learn (PEP 517) ... |的位置等待!不知道是什么原因!

zhihui@zhihui-desktop:~/shl/CenterTrack/src$pip install sklearn
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting scikit-learn
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/aa/f6/75297be19f48b7a8c2577753a3a700f98fc4db49d0e5ed3820dd8dee43d4/scikit-learn-0.23.2.tar.gz (7.2 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.6/dist-packages (from scikit-learn) (1.16.1)
Collecting joblib>=0.11
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/fc/c9/f58220ac44a1592f79a343caba12f6837f9e0c04c196176a3d66338e1ea8/joblib-0.17.0-py3-none-any.whl (301 kB)
Requirement already satisfied: scipy>=0.19.1 in /home/zhihui/.local/lib/python3.6/site-packages (from scikit-learn) (1.4.1)
Collecting threadpoolctl>=2.0.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f7/12/ec3f2e203afa394a149911729357aa48affc59c20e2c1c8297a60f33f133/threadpoolctl-2.1.0-py3-none-any.whl (12 kB)
Building wheels for collected packages: scikit-learn
  Building wheel for scikit-learn (PEP 517) ... |

此时可以换一种方式安装,使用apt-get安装python的sklearn库包参考):

sudo apt-get install python3-sklearn

zhihui@zhihui-desktop:~/shl/CenterTrack/src$ sudo apt-get install python3-sklearn
[sudo] password for zhihui: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  activity-log-manager archdetect-deb bamfdaemon bogl-bterm busybox-static compiz-core compiz-plugins-default cryptsetup-bin debhelper
  dh-autoreconf dh-strip-nondeterminism dpkg-repack gir1.2-accounts-1.0 gir1.2-gdata-0.0 gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0
  gir1.2-harfbuzz-0.0 gir1.2-rb-3.0 gir1.2-signon-1.0 gir1.2-timezonemap-1.0 gir1.2-totem-1.0 gir1.2-totemplparser-1.0 gir1.2-xkl-1.0
  gnome-calculator gnome-system-monitor grub-common gtk3-nocsd icu-devtools kde-window-manager kpackagetool5 kwayland-data kwin-common
  kwin-x11 libarchive-cpio-perl libatkmm-1.6-1v5 libboost-python1.65.1 libcairomm-1.0-1v5 libcolumbus1-common libcolumbus1v5 libcompizconfig0
  libdebian-installer4 libdecoration0 libdmapsharing-3.0-2 libegl1-mesa-dev libeigen3-dev libfile-stripnondeterminism-perl libgeonames-common
  libgeonames0 libgles2-mesa-dev libglibmm-2.4-1v5 libgpod-common libgpod4 libgraphite2-dev libgtk3-nocsd0 libgtkmm-3.0-1v5
  libharfbuzz-gobject0 libicu-le-hb0 libiculx60 libkdecorations2-5v5 libkdecorations2private5v5 libkf5activities5 libkf5declarative-data
  libkf5declarative5 libkf5globalaccelprivate5 libkf5idletime5 libkf5kcmutils-data libkf5kcmutils5 libkf5package-data libkf5package5
  libkf5plasma5 libkf5quickaddons5 libkf5waylandclient5 libkf5waylandserver5 libkscreenlocker5 libkwin4-effect-builtins1 libkwineffects11
  libkwinglutils11 libkwinxrenderutils11 libmail-sendmail-perl libnm-gtk0 liborc-0.4-dev liborc-0.4-dev-bin libpanel-applet3
  libpangomm-1.4-1v5 libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libpinyin-data libpinyin13 libqt5designer5 libqt5help5
  libqt5positioning5 libqt5sensors5 libqt5sql5 libqt5test5 libqt5webchannel5 libqt5webkit5 libsgutils2-2 libsignon-glib1
  libsys-hostname-long-perl libtimezonemap-data libtimezonemap1 libunity-control-center1 libunity-core-6.0-9 libunity-misc4 libwayland-bin
  libwayland-dev libxcb-composite0 libxcb-cursor0 libxcb-damage0 libxrandr-dev libxrender-dev libzeitgeist-1.0-1 os-prober pkg-config
  po-debconf qml-module-org-kde-kquickcontrolsaddons rdate session-shortcuts tasksel tasksel-data unity-asset-pool unity-greeter
  unity-lens-applications unity-lens-files unity-lens-music unity-lens-video unity-schemas unity-scope-video-remote
  unity-scopes-master-default unity-scopes-runner x11proto-randr-dev
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  python3-attr python3-decorator python3-joblib python3-nose python3-pluggy python3-py python3-pytest python3-scipy python3-sklearn-lib
Suggested packages:
  python-attr-doc python-nose-doc subversion python-scipy-doc python3-dap python-sklearn-doc ipython3
The following NEW packages will be installed:
  python3-attr python3-decorator python3-joblib python3-nose python3-pluggy python3-py python3-pytest python3-scipy python3-sklearn
  python3-sklearn-lib
0 upgraded, 10 newly installed, 0 to remove and 5 not upgraded.
Need to get 11.6 MB of archives.
After this operation, 51.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 python3-attr all 17.4.0-2 [23.8 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 python3-decorator all 4.1.2-1 [9,364 B]
Get:3 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 python3-joblib all 0.11-1 [109 kB]
Get:4 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 python3-nose all 1.3.7-3 [115 kB]
Get:5 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 python3-pluggy all 0.6.0-1 [12.3 kB]
Get:6 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 python3-py all 1.5.2-1 [65.2 kB]
Get:7 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 python3-pytest all 3.3.2-2 [142 kB]
Get:8 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 python3-scipy arm64 0.19.1-2ubuntu1 [8,622 kB]                                
Get:9 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 python3-sklearn-lib arm64 0.19.1-3 [1,100 kB]                                 
Get:10 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 python3-sklearn all 0.19.1-3 [1,373 kB]                                      
Fetched 11.6 MB in 1min 30s (129 kB/s)                                                                                                         
Selecting previously unselected package python3-attr.
(Reading database ... 164356 files and directories currently installed.)
Preparing to unpack .../0-python3-attr_17.4.0-2_all.deb ...
Unpacking python3-attr (17.4.0-2) ...
Selecting previously unselected package python3-decorator.
Preparing to unpack .../1-python3-decorator_4.1.2-1_all.deb ...
Unpacking python3-decorator (4.1.2-1) ...
Selecting previously unselected package python3-joblib.
Preparing to unpack .../2-python3-joblib_0.11-1_all.deb ...
Unpacking python3-joblib (0.11-1) ...
Selecting previously unselected package python3-nose.
Preparing to unpack .../3-python3-nose_1.3.7-3_all.deb ...
Unpacking python3-nose (1.3.7-3) ...
Selecting previously unselected package python3-pluggy.
Preparing to unpack .../4-python3-pluggy_0.6.0-1_all.deb ...
Unpacking python3-pluggy (0.6.0-1) ...
Selecting previously unselected package python3-py.
Preparing to unpack .../5-python3-py_1.5.2-1_all.deb ...
Unpacking python3-py (1.5.2-1) ...
Selecting previously unselected package python3-pytest.
Preparing to unpack .../6-python3-pytest_3.3.2-2_all.deb ...
Unpacking python3-pytest (3.3.2-2) ...
Selecting previously unselected package python3-scipy.
Preparing to unpack .../7-python3-scipy_0.19.1-2ubuntu1_arm64.deb ...
Unpacking python3-scipy (0.19.1-2ubuntu1) ...
Selecting previously unselected package python3-sklearn-lib.
Preparing to unpack .../8-python3-sklearn-lib_0.19.1-3_arm64.deb ...
Unpacking python3-sklearn-lib (0.19.1-3) ...
Selecting previously unselected package python3-sklearn.
Preparing to unpack .../9-python3-sklearn_0.19.1-3_all.deb ...
Unpacking python3-sklearn (0.19.1-3) ...
Setting up python3-py (1.5.2-1) ...
Setting up python3-sklearn-lib (0.19.1-3) ...
Setting up python3-pluggy (0.6.0-1) ...
Setting up python3-nose (1.3.7-3) ...
Setting up python3-attr (17.4.0-2) ...
Setting up python3-decorator (4.1.2-1) ...
Setting up python3-joblib (0.11-1) ...
Setting up python3-scipy (0.19.1-2ubuntu1) ...
Setting up python3-pytest (3.3.2-2) ...
Setting up python3-sklearn (0.19.1-3) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
zhihui@zhihui-desktop:~/shl/CenterTrack/src$ python
Python 3.6.9 (default, Oct  8 2020, 12:12:24) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn
>>> sklearn.__version__
'0.19.1'
>>> exit()
zhihui@zhihui-desktop:~/shl/CenterTrack/src$ 

5 在Jetson NX运行CenterTrack项目

1、运行CenterTrack在Jetson NX上

python demo.py tracking --load_model ../model/coco_tracking.pth --demo ../videos/cars.mp4

zhihui@zhihui-desktop:~/shl/CenterTrack/src$ python demo.py tracking --load_model ../model/coco_tracking.pth --demo ../videos/cars.mp4 
Running tracking
Using tracking threshold for out threshold! 0.3
Fix size testing.
training chunk_sizes: [32]
input h w: 512 512
heads {'hm': 80, 'reg': 2, 'wh': 2, 'tracking': 2}
weights {'hm': 1, 'reg': 1, 'wh': 0.1, 'tracking': 1}
head conv {'hm': [256], 'reg': [256], 'wh': [256], 'tracking': [256]}
Creating model...
Using node type: (<class 'model.networks.dla.DeformConv'>, <class 'model.networks.dla.DeformConv'>)
Warning: No ImageNet pretrain!!
loaded ../model/coco_tracking.pth, epoch 70
Drop parameter base.pre_hm_layer.0.weight.
Drop parameter base.pre_hm_layer.1.weight.
Drop parameter base.pre_hm_layer.1.bias.
Drop parameter base.pre_hm_layer.1.running_mean.
Drop parameter base.pre_hm_layer.1.running_var.
Drop parameter base.pre_hm_layer.1.num_batches_tracked.
out_name cars.mp4
Gtk-Message: 14:58:11.023: Failed to load module "canberra-gtk-module"
Initialize tracking!
Traceback (most recent call last):
  File "demo.py", line 128, in <module>
    demo(opt)
  File "demo.py", line 83, in demo
    ret = detector.run(img)
  File "/home/zhihui/shl/CenterTrack/src/lib/detector.py", line 119, in run
    images, self.pre_images, pre_hms, pre_inds, return_time=True)
  File "/home/zhihui/shl/CenterTrack/src/lib/detector.py", line 347, in process
    dets = generic_decode(output, K=self.opt.K, opt=self.opt)
  File "/home/zhihui/shl/CenterTrack/src/lib/model/decode.py", line 94, in generic_decode
    scores, inds, clses, ys0, xs0 = _topk(heat, K=K)
  File "/home/zhihui/shl/CenterTrack/src/lib/model/utils.py", line 77, in _topk
    topk_ys   = (topk_inds / width).int().float()
RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future release div will perform true division as in Python 3. Use true_divide or floor_divide (// in Python) instead.

2、如果报错:RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future release div will perform true division as in Python 3. Use true_divide or floor_divide (// in Python) instead.,这是因为在pytorch1.5中的/中tensor除以一个整数的操作,在pytorch1.6中已经不支持了!([]参考(https://my.oschina.net/u/4389867/blog/4531779))

CenterTrack/src/lib/model/utils.py中的77行和81行代码修改如下即可:

 #topk_ys   = (topk_inds / width).int().float()
  topk_ys   = torch.floor_divide(topk_inds, width).int().float()
  topk_xs   = (topk_inds % width).int().float()

  topk_score, topk_ind = torch.topk(topk_scores.view(batch, -1), K)
  #topk_clses = (topk_ind / K).int()
  topk_clses = torch.floor_divide(topk_ind, K).int()

3、成功在Jetson NX上跑通CenterTrack目标跟踪模型,就是速度有点慢,后面会想办法把模型转为TensorRT

zhihui@zhihui-desktop:~/shl/CenterTrack/src$ python demo.py tracking --load_model ../model/coco_tracking.pth --demo ../videos/cars.mp4 
Running tracking
Using tracking threshold for out threshold! 0.3
Fix size testing.
training chunk_sizes: [32]
input h w: 512 512
heads {'hm': 80, 'reg': 2, 'wh': 2, 'tracking': 2}
weights {'hm': 1, 'reg': 1, 'wh': 0.1, 'tracking': 1}
head conv {'hm': [256], 'reg': [256], 'wh': [256], 'tracking': [256]}
Creating model...
Using node type: (<class 'model.networks.dla.DeformConv'>, <class 'model.networks.dla.DeformConv'>)
Warning: No ImageNet pretrain!!
loaded ../model/coco_tracking.pth, epoch 70
Drop parameter base.pre_hm_layer.0.weight.
Drop parameter base.pre_hm_layer.1.weight.
Drop parameter base.pre_hm_layer.1.bias.
Drop parameter base.pre_hm_layer.1.running_mean.
Drop parameter base.pre_hm_layer.1.running_var.
Drop parameter base.pre_hm_layer.1.num_batches_tracked.
out_name cars.mp4
Gtk-Message: 15:07:56.754: Failed to load module "canberra-gtk-module"
Initialize tracking!
frame 1 |tot 4.120s |load 0.000s |pre 0.043s |net 3.978s |dec 0.078s |post 0.018s |merge 0.000s |display 0.074s |
frame 2 |tot 0.301s |load 0.000s |pre 0.074s |net 0.211s |dec 0.009s |post 0.004s |merge 0.000s |display 0.017s |
frame 3 |tot 0.263s |load 0.000s |pre 0.031s |net 0.216s |dec 0.009s |post 0.004s |merge 0.000s |display 0.016s |
frame 4 |tot 0.248s |load 0.000s |pre 0.031s |net 0.201s |dec 0.009s |post 0.004s |merge 0.000s |display 0.014s |
frame 5 |tot 0.311s |load 0.000s |pre 0.027s |net 0.268s |dec 0.010s |post 0.004s |merge 0.000s |display 0.027s |
frame 6 |tot 0.313s |load 0.000s |pre 0.030s |net 0.265s |dec 0.010s |post 0.004s |merge 0.000s |display 0.037s |
frame 7 |tot 0.300s |load 0.000s |pre 0.037s |net 0.248s |dec 0.009s |post 0.004s |merge 0.000s |display 0.032s |
frame 8 |tot 0.327s |load 0.000s |pre 0.037s |net 0.268s |dec 0.012s |post 0.006s |merge 0.000s |display 0.021s |
frame 9 |tot 0.239s |load 0.000s |pre 0.027s |net 0.196s |dec 0.010s |post 0.004s |merge 0.001s |display 0.015s |
frame 10 |tot 0.241s |load 0.000s |pre 0.029s |net 0.196s |dec 0.009s |post 0.004s |merge 0.000s |display 0.014s |
frame 11 |tot 0.247s |load 0.000s |pre 0.028s |net 0.203s |dec 0.008s |post 0.005s |merge 0.000s |display 0.016s |
frame 12 |tot 0.249s |load 0.000s |pre 0.034s |net 0.199s |dec 0.009s |post 0.004s |merge 0.000s |display 0.015s |
frame 13 |tot 0.248s |load 0.000s |pre 0.030s |net 0.201s |dec 0.009s |post 0.005s |merge 0.000s |display 0.016s |
frame 14 |tot 0.251s |load 0.000s |pre 0.029s |net 0.206s |dec 0.008s |post 0.005s |merge 0.000s |display 0.016s |
frame 15 |tot 0.245s |load 0.000s |pre 0.035s |net 0.194s |dec 0.009s |post 0.004s |merge 0.000s |display 0.033s |
frame 16 |tot 0.314s |load 0.000s |pre 0.033s |net 0.266s |dec 0.009s |post 0.004s |merge 0.000s |display 0.033s |
frame 17 |tot 0.280s |load 0.000s |pre 0.030s |net 0.235s |dec 0.008s |post 0.004s |merge 0.000s |display 0.033s |
frame 18 |tot 0.312s |load 0.000s |pre 0.026s |net 0.268s |dec 0.010s |post 0.005s |merge 0.000s |display 0.036s |
frame 19 |tot 0.315s |load 0.000s |pre 0.031s |net 0.268s |dec 0.010s |post 0.004s |merge 0.000s |display 0.037s |
frame 20 |tot 0.259s |load 0.000s |pre 0.041s |net 0.203s |dec 0.009s |post 0.003s |merge 0.000s |display 0.034s |
frame 21 |tot 0.321s |load 0.000s |pre 0.027s |net 0.268s |dec 0.011s |post 0.008s |merge 0.001s |display 0.041s |
frame 22 |tot 0.256s |load 0.000s |pre 0.041s |net 0.201s |dec 0.009s |post 0.003s |merge 0.000s |display 0.031s |
frame 23 |tot 0.253s |load 0.000s |pre 0.039s |net 0.198s |dec 0.009s |post 0.004s |merge 0.000s |display 0.033s |
frame 24 |tot 0.257s |load 0.000s |pre 0.045s |net 0.196s |dec 0.009s |post 0.004s |merge 0.000s |display 0.033s |
frame 25 |tot 0.262s |load 0.000s |pre 0.047s |net 0.198s |dec 0.010s |post 0.004s |merge 0.000s |display 0.036s |
frame 26 |tot 0.319s |load 0.000s |pre 0.030s |net 0.267s |dec 0.014s |post 0.005s |merge 0.000s |display 0.035s |
frame 27 |tot 0.265s |load 0.000s |pre 0.045s |net 0.205s |dec 0.009s |post 0.003s |merge 0.000s |display 0.031s |
frame 28 |tot 0.267s |load 0.000s |pre 0.048s |net 0.202s |dec 0.009s |post 0.004s |merge 0.000s |display 0.035s |
frame 29 |tot 0.319s |load 0.000s |pre 0.030s |net 0.270s |dec 0.010s |post 0.004s |merge 0.000s |display 0.036s |
frame 30 |tot 0.272s |load 0.000s |pre 0.028s |net 0.228s |dec 0.009s |post 0.004s |merge 0.000s |display 0.033s |
frame 31 |tot 0.321s |load 0.000s |pre 0.029s |net 0.265s |dec 0.013s |post 0.010s |merge 0.000s |display 0.066s |
frame 32 |tot 0.240s |load 0.000s |pre 0.030s |net 0.194s |dec 0.009s |post 0.004s |merge 0.000s |display 0.033s |
frame 33 |tot 0.320s |load 0.000s |pre 0.027s |net 0.266s |dec 0.012s |post 0.012s |merge 0.001s |display 0.034s |
frame 34 |tot 0.265s |load 0.000s |pre 0.043s |net 0.207s |dec 0.008s |post 0.004s |merge 0.000s |display 0.034s |
frame 35 |tot 0.327s |load 0.000s |pre 0.035s |net 0.270s |dec 0.011s |post 0.005s |merge 0.000s |display 0.048s |
frame 36 |tot 0.331s |load 0.000s |pre 0.047s |net 0.267s |dec 0.010s |post 0.004s |merge 0.000s |display 0.033s |
frame 37 |tot 0.315s |load 0.000s |pre 0.030s |net 0.268s |dec 0.010s |post 0.004s |merge 0.000s |display 0.034s |
frame 38 |tot 0.317s |load 0.000s |pre 0.032s |net 0.267s |dec 0.011s |post 0.004s |merge 0.000s |display 0.036s |
frame 39 |tot 0.292s |load 0.000s |pre 0.039s |net 0.238s |dec 0.009s |post 0.004s |merge 0.000s |display 0.033s |
frame 40 |tot 0.254s |load 0.000s |pre 0.040s |net 0.200s |dec 0.008s |post 0.004s |merge 0.000s |display 0.014s |
frame 41 |tot 0.236s |load 0.000s |pre 0.031s |net 0.191s |dec 0.008s |post 0.004s |merge 0.000s |display 0.013s |
frame 42 |tot 0.253s |load 0.000s |pre 0.042s |net 0.195s |dec 0.009s |post 0.003s |merge 0.000s |display 0.014s |
frame 43 |tot 0.236s |load 0.000s |pre 0.027s |net 0.193s |dec 0.009s |post 0.004s |merge 0.000s |display 0.013s |
frame 44 |tot 0.237s |load 0.000s |pre 0.028s |net 0.193s |dec 0.009s |post 0.004s |merge 0.000s |display 0.015s |
frame 45 |tot 0.237s |load 0.000s |pre 0.027s |net 0.195s |dec 0.010s |post 0.004s |merge 0.000s |display 0.014s |

参考:https://www.coder.work/article/4985382 # 从源码安装
参考:https://blog.csdn.net/zt1091574181/article/details/108222306 # 从编译好的文件
参考:https://blog.csdn.net/qq_45779334/article/details/108640247
参考:https://www.jianshu.com/p/ccaf688f54c0 # 解决安装过程中的错误

欢迎大家关注笔者,你的关注是我持续更博的最大动力


原创文章,转载告知,盗版必究

微信:suihailiang0816
QQ:931762054
wx公众号:仰望星空的小随
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 猿与汪的秘密 设计师:白松林 返回首页