Xavier(基于arrch64架构)搭建second点云目标检测环境! |
- 首先声明声明一下,在Xavier上编译各种东西实在是太难了,希望对你有所帮助,中间遇到各种坑!
- 系统我刷机使用的是Jetpack4.2,刷机教程可以参考上一篇博客:Xavier(基于arrch64架构)刷机Jetpack4.2!)
- 环境信息参考如下(torch和torchvision使用pip安装),在最后附录下面展示!
- second点云项目github地址:https://github.com/traveller59/second.pytorch
- 此外在使用pip的时候我们可以制定pip的源
# 阿里源
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
# 豆瓣
pip install -r requirements.txt -i https://pypi.douban.com/simple/
# 清华大学
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
在给Xavier刷完机之后,首先是安装Cmake,要进行源安装,然后运行./boostrad那个,然后sudo make && make install。最后需要将你的cmake路径添加到环境变量中去。
export PATH=$PATH:/your_camke_path/
这里参考我之前的博客,使用一个miniforge的软件包,个人感觉相比其它方法,这个方法最棒。 博客链接:『NVIDIA Jetson Xavier笔记』Xavier(基于arrch64架构)安装anaconda!
激活进入second虚拟环境之后, 这里我们在安装numba包之前要安装一些依赖:
sudo apt-get install llvm-7
查看llvm的路径(执行下面命令后会在终端显示llvm的安装路径):
which llvm-config-7
执行如下命令:
export LLVM_CONFIG=/usr/bin/llvm-config-7
pip install llvmlite==0.29.0
pip install numba==0.44.1
到此,如果安装没问题的话,在python环境下看能否import numba成功,可以的话说明已经安装成功,接下来在.bashrc下面添加导出路径。
export NUMBAPRO_CUDA_DRIVER=/usr/lib/aarch64-linux-gnu/libcuda.so # (set your Xavier cuda lib path)
export NUMBAPRO_NVVM=/usr/local/cuda/nvvm/lib64/libnvvm.so # set your libnvvm path
export NUMBAPRO_LIBDEVICE=/usr/local/cuda/nvvm/libdevice
Xavier安装pytotrch刚开始不太容易,因为没有直接安装的脚本(需要编译,坑特别多),幸好有这个NVIDIA官方提供了.whl文件,链接为:Welcome to the new NVIDIA Developer Forums!,按照里面的安装步骤就可以,然后就可以按抓给你对应的torchvision版本。
如果下载过程,可以直接用我百度云链接:提取码:o03n
pip install torch-1.1.0-cp36-cp36m-linux_aarch64.whl
下面是安装torchvision,参考nvidia官方里的issues的答案:
sudo apt-get install libjpeg-dev zlib1g-dev
git clone --branch v0.3.0 https://github.com/pytorch/vision torchvision
cd torchvision
sudo python setup.py install
cd ../ # attempting to load torchvision from build dir will result in import error
不同版本的torch所对应的torchvision:
PyTorch v1.0 - torchvision v0.2.2
PyTorch v1.1 - torchvision v0.3.0
PyTorch v1.2 - torchvision v0.4.0
PyTorch v1.3 - torchvision v0.4.2
在这部分花的时间也不少,因为编译不过。这里使用的是Spconv 1.1。
git clone https://github.com/traveller59/spconv --recursive
记得要检查一下,third-party里面的pybind11 是否下载完整,否则容易出错。编译完成后会在dist文件夹下有 spconv 1.1的whl 文件,然后 pip3 install 安装就可以。这里为了方便我百度云直接提供了编译好的.whl文件,只需要直接pip一下。 百度云链接:提取码:o03n
pip install spconv-1.1-cp36-cp36m-linux_aarch64.whl
git clone https://github.com/NVIDIA/apex.git
cd apex
python setup.py install --cpp_ext --cuda_ext
(second) sl@sl-xavier:~/zhang/second.pytorch/second$ export PYTHONPATH=/home/zhang/second.pytorch/
(second) sl@sl-xavier:~/zhang/second.pytorch/second$ python ./pytorch/train.py evaluate --config_path=./configs/all.fhd.config --model_dir=./model_dirb --measure_time=True --batch_size=1
......
......
[ 41 800 1104]
Restoring parameters from /home/sl/zhang/second.pytorch/second/model_dirb/voxelnet-63550.pt
feature_map_size [1, 100, 138]
remain number of infos: 3769
Generate output labels...
[100.0%][===================>][4.22it/s][16:16>00:00]
generate label finished(3.84/s). start eval:
==========================================================================================
avg example to torch time: 21.604 ms
avg prep time: 16.747 ms
avg voxel_feature_extractor time = 2.204 ms
avg middle forward time = 166.750 ms
avg rpn forward time = 26.099 ms
avg predict time = 24.597 ms
all_time : 258.001 ms
注意: 程序运行过程中,难免会遇到各种各样的问题,我遇到的问题是opencv-python安装不了,后来考虑到只是简单的测试,就把cv2包注销掉了。
File "<__array_function__ internals>", line 6, in linspace
File "/home/sl/miniforge-pypy3/envs/second/lib/python3.6/site-packages/numpy/core/function_base.py", line 121, in linspace
.format(type(num)))
TypeError: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.
参加github官网issues:To solve it, you can either downgrade your numpy, or modify utils/eval.py, line 704:
for i in range(overlap_ranges.shape[1]):
for j in range(overlap_ranges.shape[2]):
a, b, c = overlap_ranges[:, i, j] #extracting the three numbers
min_overlaps[:, i, j] = np.linspace(a, b, int(c)) #casting to integer
#min_overlaps[:, i, j] = np.linspace(*overlap_ranges[:, i, j])
官方新推出jtop工具,专门用来查看jetson的CPU、GPU等信息,使用方法也很简单!
sudo -H pip install jetson-stats
如果提示没有安装pip,执行如下命令安装pip。安装命令如下:
sudo apt-get install python-pip
直接在命令行输入:
sudo jtop
NVIDIA Jetson Xavier是一个更加丰富的计算环境。除了增加4个CPU核外,Xavier还增加了深度学习加速器(DLA)和视觉加速器(VA)。这些新添加的内容也可以使用nvpmodel进行配置!nvpmodel在7种不同模式下定义了4种不同的power envelope。power envelope有10瓦、15瓦、30瓦,还有——
nvpmodel介绍了Jetson AGX Xavier上的七种不同的“模式”:
注意表中几个名词:
GPU TPC – GPU Texture/Processor Cluster
DLA – Deep Learning Accelerator
VA – Vision Accelerator
默认模式是15W (MODE_15W, ID:2),你可以通过这个方式看到:
sudo nvpmodel --query
如果我们想换到表格中的0模式,那么我们可以执行:
sudo nvpmodel -m 0
然后再用查询命令看一下是否已经切换到0模式了:
注意:nvpmodel设置更改后,重启后数值会保持。
(second) sl@sl-xavier:~$ conda list
# packages in environment at /home/sl/miniforge-pypy3/envs/second:
#
# Name Version Build Channel
_openmp_mutex 4.5 0_gnu conda-forge
blosc 1.19.0 he1b5a44_0 conda-forge
brotli 1.0.7 he1b5a44_1002 conda-forge
bzip2 1.0.8 h516909a_2 conda-forge
ca-certificates 2020.4.5.2 hecda079_0 conda-forge
certifi 2020.4.5.2 py36h9f0ad1d_0 conda-forge
charls 2.1.0 he1b5a44_2 conda-forge
cloudpickle 1.4.1 py_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
cycler 0.10.0 py_2 conda-forge
cytoolz 0.10.1 py36h516909a_0 conda-forge
dask-core 2.17.2 py_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
decorator 4.4.2 py_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
fire 0.3.1 pypi_0 pypi
freetype 2.10.2 he06d7ca_0 conda-forge
giflib 5.2.1 h516909a_2 conda-forge
icu 64.2 h4c5d2ac_1 conda-forge
imagecodecs 2020.5.30 py36hcd4facd_1 conda-forge
imageio 2.8.0 py_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
jpeg 9d h6dd45c4_0 conda-forge
jxrlib 1.1 h516909a_2 conda-forge
kiwisolver 1.2.0 py36hdb11119_0 conda-forge
lcms2 2.9 hbd6801e_2 conda-forge
ld_impl_linux-aarch64 2.34 h326052a_5 conda-forge
libaec 1.0.4 he1b5a44_1 conda-forge
libblas 3.8.0 10_openblas conda-forge
libcblas 3.8.0 10_openblas conda-forge
libffi 3.2.1 h4c5d2ac_1007 conda-forge
libgcc-ng 7.5.0 h8e86211_6 conda-forge
libgfortran-ng 7.5.0 hca8aa85_6 conda-forge
libgomp 7.5.0 h8e86211_6 conda-forge
liblapack 3.8.0 10_openblas conda-forge
libpng 1.6.37 hed695b0_1 conda-forge
libprotobuf 3.12.3 h8b12597_0 conda-forge
libstdcxx-ng 7.5.0 hca8aa85_6 conda-forge
libtiff 4.1.0 h6fdbc6b_6 conda-forge
libwebp-base 1.1.0 h516909a_3 conda-forge
libzopfli 1.0.3 he1b5a44_0 conda-forge
llvmlite 0.29.0 pypi_0 pypi
lz4-c 1.9.2 he1b5a44_1 conda-forge
matplotlib 3.2.1 0 conda-forge
matplotlib-base 3.2.1 py36h0f30586_0 conda-forge
ncurses 6.1 hf484d3e_1002 conda-forge
networkx 2.4 py_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
numba 0.44.1 pypi_0 pypi
numpy 1.18.5 py36h3849536_0 conda-forge
olefile 0.46 py_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
openblas 0.3.6 h6e990d7_2 conda-forge
openjpeg 2.3.1 h981e76c_3 conda-forge
openssl 1.1.1g h516909a_0 conda-forge
pandas 1.0.4 py36h7c3b610_0 conda-forge
pillow 7.1.2 py36h8328e55_0 conda-forge
pip 20.1.1 py_1 conda-forge
protobuf 3.12.2 pypi_0 pypi
psutil 5.7.0 pypi_0 pypi
pyparsing 2.4.7 py_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
python 3.6.10 h8356626_1011_cpython conda-forge
python-dateutil 2.8.1 py_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
python_abi 3.6 1_cp36m conda-forge
pytz 2020.1 py_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pywavelets 1.1.1 py36h68bb277_1 conda-forge
pyyaml 5.3.1 py36h8c4c3a4_0 conda-forge
readline 8.0 h75b48e3_0 conda-forge
scikit-image 0.17.2 py36h7c3b610_1 conda-forge
scipy 1.4.1 py36h3a855aa_3 conda-forge
seaborn 0.10.1 py_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
setuptools 47.1.1 py36h9f0ad1d_0 conda-forge
six 1.15.0 pypi_0 pypi
snappy 1.1.8 he1b5a44_1 conda-forge
spconv 1.1 pypi_0 pypi
sqlite 3.30.1 h283c62a_0 conda-forge
tensorboardx 2.0 py_0 conda-forge
termcolor 1.1.0 pypi_0 pypi
tifffile 2020.6.3 py_1 conda-forge
tk 8.6.10 hed695b0_0 conda-forge
toolz 0.10.0 py_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
torch 1.1.0 pypi_0 pypi
tornado 6.0.4 py36h8c4c3a4_1 conda-forge
wheel 0.34.2 py_1 conda-forge
xz 5.2.5 h6dd45c4_0 conda-forge
yaml 0.2.5 h516909a_0 conda-forge
zlib 1.2.11 h516909a_1006 conda-forge
zstd 1.4.4 h6597ccf_3 conda-forge
(second) sl@sl-xavier:~$ pip list
Package Version
--------------- -------------------
certifi 2020.4.5.2
cloudpickle 1.4.1
cycler 0.10.0
cytoolz 0.10.1
dask 2.17.2
decorator 4.4.2
fire 0.3.1
imagecodecs 2020.5.30
imageio 2.8.0
kiwisolver 1.2.0
llvmlite 0.29.0
matplotlib 3.2.1
networkx 2.4
numba 0.44.1
numpy 1.18.5
olefile 0.46
pandas 1.0.4
Pillow 7.1.2
pip 20.1.1
protobuf 3.12.3
psutil 5.7.0
pyparsing 2.4.7
python-dateutil 2.8.1
pytz 2020.1
PyWavelets 1.1.1
PyYAML 5.3.1
scikit-image 0.17.2
scipy 1.4.1
seaborn 0.10.1
setuptools 47.1.1.post20200529
six 1.15.0
spconv 1.1
tensorboardX 2.0
termcolor 1.1.0
tifffile 2020.6.3
toolz 0.10.0
torch 1.1.0
torchvision 0.3.0
tornado 6.0.4
wheel 0.34.2
- Jetson 查看CPU、内存、GPU使用情况
- NVIDIA_Jetson_Xavier安装second.pytorch环境
- Xavier 运行 SECOND点云目标检测网络(一)
- second.pytorch环境配置及训练运行折腾史
- 让NVIDIA Jetson AGX Xavier火力全开的秘密
- jetson平台实用命令