一.jetpack 3.2刷机TX2,刷机完成后TX2上有ubuntu16.04操作系统,cuda9.0+cudnn5,opencv3.3.1
二.配置caffe
1.安装各种包以及依赖
sudo apt-get update
sudo apt-get install build-essential cmake git pkg-config
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install libatlas-base-dev
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
2.安装python和其余依赖项
sudo apt-get install python
sudo apt-get install python-dev
sudo apt-get install python-numpy
sudo apt-get install ipython
sudo apt-get install ipython-notebook
sudo apt-get install python-sklearn
sudo apt-get install python-skimage
sudo apt-get install python-protobuf
3.安装easydict
sudo apt-get install python-pip
sudo pip install easydict
三.移植PVANet
1.pva-faster-rcnn工程已在主机GPU和TX1上跑通,将它拷贝到TX2上;
2.建立Cython模块:
cd pva-faster-rcnn/lib
gedit setup.py
此处需要根据GPU 计算能力(查看地址:https://developer.nvidia.com/cuda-gpus)
修改lib下的setup.py第135行 ‘nvcc’: [’-arch=sm_35’,如果是TX2,计算能力为6.2,则修改为’nvcc’: [’-arch=sm_62’,如果是TITAN V,计算能力为7.0,则修改为’nvcc’: [’-arch=sm_70’
make -j4
#开始编译,TX2有四核CPU
3.编译caffe及pycaffe
cd pva-faster-rcnn/caffe-fast-rcnn
cp Makefile.config.example Makefile.config
sudo gedit Makefile.config
修改Makefile.config文件:
1)去掉USE_CUDNN := 1,OPENCV_VERSION := 3,WITH_PYTHON_LAYER := 1,BLAS=atlas的注释
2)注释掉CUDA_ARCH的前两行
CUDA_ARCH := #-gencode arch=compute_20,code=sm_20 \
#-gencode arch=compute_20,code=sm_21
3)修改库路径为:
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu/hdf5/serial/
注:网上有其他人做法:修改Makefile中181行的hdf5_hl和hdf5,LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial,但我没有修改Makefile文件,编译没出现错误
make –j4 #开始编译
make pycaffe –j4
4.运行视频测试demo($pva-faster-rcnn)
./tools/test_pvanet.py
#已修改test_pvanet.py文件使其可以测试视频
四.错误汇总:
1.跑demo时出现错误File “/pva-faster-rcnn/tools/…/lib/fast_rcnn/config.py”, line 23, in from easydict import EasyDict as edict ImportError: No module named easydict
原因:未安装EasyDict所致,
解决:
python
from easydict import EasyDict #if this doesn't give an error then you have easydict installed.If an ImportError: No module named easydict,then you need to install easydicts
sudo apt-get update
sudo apt-get install python-pip
pip -V #check if pip is successfully installed
sudo pip install easydict
2.跑demo时出现错误nms_wrapper.py 中from nms.gpu_nms import gpu_nms ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory
原因:/lib/nms/gpu_nms.so是工程之前在TX1上跑用cuda8.0编译产生的,而TX2上装的是cuda9.0,
解决:删掉gpu_nms.so,
cd pva-faster-rcnn/lib
make -j4 #gpu_nms.so is newly generated
3.修改Makefile.config文件时切记不要直接拷贝网上别人的修改,最好照着手敲,因为直接拷贝很可能会拷进一些不显示的未知字符,然后make时会出现各种奇特错误,难以追查原因.
另外遇到错误要根据自己机子及项目工程的情况仔细判断,细细排查,总会解决的.
参考的博客:
[1]初学JetsonTX2之安装CAFFE:https://blog.youkuaiyun.com/dhaduce/article/details/80155121
[2]TX2配置安装pva-faster-rcnn:https://blog.youkuaiyun.com/zong596568821xp/article/details/80407810
[3]jetson tx2 编译及运行faster-rcnn的物体检测例程demo:https://blog.youkuaiyun.com/qq_41943402/article/details/81198574
[5]TX2 配置caffe-经验版:https://blog.youkuaiyun.com/qq_23999499/article/details/82918559