计算机视觉caffe之路第一篇:Ubuntu16.04_Jetson TX1_Caffe_ssd环境配置

来源:互联网 发布:宏观审慎管理知乎 编辑:程序博客网 时间:2024/06/05 08:53

1.安装依赖包

依次安装以下依赖项,如果不想每一次install都出现yes or no的提示项,可以在命令末尾加上“-y”。

 sudo apt-get install build-essential -y #必要的编译工具依赖 sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler sudo apt-get install --no-install-recommends libboost-all-dev sudo apt-get install libatlas-base-dev sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

2.安装easy_install和pip

wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.pysudo python ez_setup.pywget https://bootstrap.pypa.io/get-pip.pysudo python get-pip.py

3.安装python常用库

sudo apt-get install libblas-dev liblapack-dev libatlas-base-dev gfortran python-numpy

4.克隆ssd源码

在/home/ubuntu/cube/目录下:

git clone https://github.com/weiliu89/caffe.gitcd caffe/git checkout ssd # 切换至分支ssd

5.安装pycaffe所需依赖包

cd /home/ubuntu/cube/caffe/pythonsudo su # 使用超级权限for req in $(cat "requirements.txt"); do pip install -i https://pypi.tuna.tsinghua.edu.cn/simple $req; done 

问题:有时候安装pip运行后会出现如下情况

root:~$ pip-bash: /usr/bin/pip: No such file or directory         root:~$ which pip/usr/local/bin/pip  

此时需要创建/usr/local/bin/pip的软连接到/usr/bin/pip,方法如下:

#ln -s 源地址  目的地址ln -s /usr/local/bin/pip   /usr/bin/pip

6.编译caffe-ssd

(1).修改Makefile.config

cd /home/ubuntu/cube/caffecp Makefile.config.example Makefile.configvim Makefile.config     
  • USE_CUDNN := 1 取消注释
  • OPENCV_VERSION := 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/
  • CUDA_ARCH := 后面加一句-gencode arch=compute_53,code=sm_53
  • 最好同时删除sm_35以下以及sm_53以上的条目

(2).修改Makefile.config

cd /home/ubuntu/cube/caffevim Makefile

修改

NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS) 

`NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)`

说明:修改这一步是为了避免出现string.h ‘memcy’ was not declared in this scope这样的错误,这种错误通常是由于gcc版本太新而导致的

(2).编译caffe-ssd

注意:编译前最好先make clean

cd /home/ubuntu/cube/caffemake cleanmake all -j4   #或者-j8根据硬件配置make test -j4make runtest -j4  #如果能运行demo,make test & runtest非必须 make pycaffe -j4 make matcaffe -j4   #可选,但要修改其他选项,参看底部文献

问题1:可能会提示找不到openblas库,安装openblas:

sudo apt-get install libopenblas-dev

然后重新编译。
测试Python环境

cd ~/caffe/pythonpythonimport caffe

可能会出警告:UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment 这种情况也不要紧,可用下面命令消除之:

import matplotlibmatplotlib.use('TkAgg')



参考资料:
Jetson TX1 开发教程(3)–安装运行Caffe-SSD
JSSD: Single Shot MultiBox Detector的安装配置和运行

原创粉丝点击