安装Ubuntu14.04
本文安装的是双系统
安装Caffe依赖
基本依赖
参考http://caffe.berkeleyvision.org/install_apt.html
安装CUDA
- 在https://developer.nvidia.com/cuda-downloads选择合适的版本下载安装
- 执行以下命令
sudo dpkg -i cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda
可能遇到的问题
- 如果CUDA装完以后提示电脑开启了secure boot导致不能兼容一些第三方应用,可以进入BIOS关闭secure boot(可能需要清除key)
- 如果在Ubuntu的登陆页面输入密码后不能进入系统,还是回到登陆页面,参考以下网址:https://www.zhihu.com/question/40729403
- 如果安装过程中遇到问题需要重装,可以直接删除/usr/local/中的cuda文件夹,然后命令行运行
apt-get autoremove
自动删除相关包 - 安装过程可以参考https://blog.csdn.net/u010837794/article/details/63251725/ 要先安装显卡驱动
编译SSD
基本过程
参考官方github:https://github.com/weiliu89/caffe/tree/ssd
可能出现的问题
- 执行
make
的时候碰到下面的问题:
/usr/include/boost/property_tree/detail/json_parser_read.hpp:257:264: error: ‘type name’ declared as function returning an array
escape
^
/usr/include/boost/property_tree/detail/json_parser_read.hpp:257:264: error: ‘type name’ declared as function returning an array
make: * [.build_release/cuda/src/caffe/layers/detection_output_layer.o] Error 1
解决方案:http://blog.csdn.net/allyli0022/article/details/62881238
2.执行make py
的时候碰到下面的问题:
python/caffe/_caffe.cpp:10:31: fatal error: numpy/arrayobject.h: 没有那个文件或目录
#include <numpy/arrayobject.h>
^
compilation terminated.
make: *** [python/caffe/_caffe.so] 错误 1
这是因为没有安装numpy,执行sudo apt-get install python-numpy
#准备数据
1.执行./data/VOC0712/create_list.sh
时显示找不到Annotations和JPEGImages里的文件,如下:
E0412 16:28:31.653440 5008 io.cpp:187] Could not open or find file/home/guyadong/data/VOCdevkit/facedata/JPEGImages/070010
这可能是因为windows和linux系统换行符不同所致,详情参考:http://blog.csdn.net/10km/article/details/70144925
2.执行./data/VOC0712/create_data.sh
时报下述错误:
ImportError: No module named caffe.proto
这是因为没有添加python路径,解决方案:http://blog.csdn.net/lanyuelvyun/article/details/73628152
3.执行./data/VOC0712/create_data.sh
时报下述错误:
ImportError: No module named _caffe
需要编译pycaffe,执行:
make pycaffe
4.执行./data/VOC0712/create_data.sh
时报下述错误:
ImportError: No module named skimage.io
是因为没有安装模块,执行:
pip install scikit-image
4.1安装scikit-image
的时候报以下错误:
error: library dfftpack has Fortran sources but no Fortran compiler found
需要安装模块:
sudo apt-get install gfortran
5.提示无法importcaffe
、_caffe
,执行:
export PYTHONPATH=$PYTHONPATH:/home/{YOUR_NAME}/caffe/python
#训练数据
要修改以下几个文档中的代码:
1.修改$CAFFE_ROOT/caffe/example/ssd_pascal.py
:
# Solver parameters.
# Defining which GPUs to use.
gpus = "0,1,2,3" ==> 改成"0"//如果是1个GPU
gpulist = gpus.split(",")
num_gpus = len(gpulist)
2.修改$CAFFE_ROOT/caffe/example/ssd_pascal.py
:
# Divide the mini-batch to different GPUs.
batch_size = 32 ==> 如果运行中出现memory不够的错误,适当改小
accum_batch_size = 32
iter_size = accum_batch_size / batch_size
3.修改$CAFFE_ROOT/caffe/Makefile.config
:
# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the lines after *_35 for compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52
-gencode arch=compute_61,code=sm_61 \
# 根据CUDA计算能力修改
CUDA计算能力参考:blog.csdn.net/real_myth/article/details/44308169
训练自己的数据(直接修改原来数据集文件夹)
直接修改data/VOCdevkit/VOC2007
中的文件(VOC2012不用,可以直接删除或更名)
- 清除
Annotations
、JPEGImages
文件夹内的内容,保留Annotations
、JPEGImages
、ImageSets
,删除其它文件夹。 - 清除
ImageSets
文件夹里的Layout
、Main
、Segmentation
里的内容,保留这3个文件夹,删除其它文件夹。 - 将自己的标记文件放在
Annotations
,图片放在JPEGImages
。 - 在
/home/ellen/data/VOCdevkit/VOC2007/ImageSets/Main
中创建test.txt
、trainal.txt
两个文件。