在NVIDIA Jetson Xavier NX上安裝llvm和numba,以及在Jetxon NX上跑通CenterTrack的目標跟蹤模型

語言: CN / TW / HK

持續創作,加速成長!這是我參與「掘金日新計劃 · 6 月更文挑戰」的第18天,點選檢視活動詳情

1 我的安裝環境如下:

1、檢視Jetson的相關版本資訊

jetson_release -v

```python [email protected]hihui-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 [email protected]:~$

```

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官網:http://releases.llvm.org/

下面是LLVM的安裝流程

1、建議安裝9.0.0或10.0.0版本Pre-Built Binaries版本:選擇AArch64-Linux版本(arm架構)下載即可,

在這裡插入圖片描述

  • llvm9.0.0下載:

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

  • llvm10.0.0下載

wget http://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 # 返回如下資訊表示安裝成功

```python [email protected]:~$ 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 [email protected]:~$

```

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的時候報錯資訊如下:

```python [email protected]:~/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: http://pypi.tuna.tsinghua.edu.cn/simple Collecting llvmlite==0.34.0 Using cached http://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. [email protected]:~/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庫檔案

python [email protected]:~/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

python [email protected]:~/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

```python [email protected]:~/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: http://pypi.tuna.tsinghua.edu.cn/simple Collecting llvmlite==0.33.0 Using cached http://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 [email protected]:~/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是個什麼東西???,具體報錯資訊如下:

```python 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版本: python git clone http://github.com/wjakob/tbb.git cd tbb/build cmake .. make -j sudo make install

也有說用apt的方式安裝tbb的我不知道是不是同一個東西,也不知道行不行,沒有嘗試,如果要試自己嘗試:

sudo apt install libtbb-dev

這裡可以檢視TBB的版本更細迭代的資訊:

安裝編譯好之後,再安裝numba,可以成功安裝numba,奈斯!!! ```python [email protected]:~/shl/tbb/build$ pip install numba Defaulting to user installation because normal site-packages is not writeable Looking in indexes: http://pypi.tuna.tsinghua.edu.cn/simple Collecting numba Downloading http://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 [email protected]:~/shl/tbb/build$

```

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

安裝sklearn的時候,會一直停滯在Building wheel for scikit-learn (PEP 517) ... |的位置等待!不知道是什麼原因!

```python [email protected]:~/shl/CenterTrack/src$pip install sklearn Defaulting to user installation because normal site-packages is not writeable Looking in indexes: http://pypi.tuna.tsinghua.edu.cn/simple Collecting scikit-learn Using cached http://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 http://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 http://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

```python [email protected]:~/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) ... [email protected]:~/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() [email protected]:~/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

```python [email protected]:~/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: (, ) 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 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中已經不支援了!([]參考(http://my.oschina.net/u/4389867/blog/4531779))

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

```python #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

```python [email protected]:~/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: (, ) 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 |

```

參考:http://www.coder.work/article/4985382 # 從原始碼安裝 參考:http://blog.csdn.net/zt1091574181/article/details/108222306 # 從編譯好的檔案 參考:http://blog.csdn.net/qq_45779334/article/details/108640247 參考:http://www.jianshu.com/p/ccaf688f54c0 # 解決安裝過程中的錯誤