caffe在ubuntu下的安装与测试

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 libhdf5-serial-dev

sudo apt-get install python-dev

sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev


sudo git clone https://github.com/BVLC/caffe.git

cd /caffe/python

for req in $(cat requirements.txt); do pip install $req; done

漫长的等待。。。。。。。。

我这里报错,没报错直接忽略

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'

.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'

原因是我这里使用了opencv3x的依赖包

解决方法:

vim Makefile

在最后添加

LIBRARIES += glog gflags protobuf leveldb snappy \  

lmdb boost_system boost_filesystem hdf5_hl hdf5 m \  

 opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs opencv_videoio 

又或者你的Makefile的编写形式是这样的

ifeq ($(USE_OPENCV),1)

    LIBRARIES += opencv_core opencv_highgui opencv_imgproc

    ifeq ($(USE_OPENCV),3)

    LIBRARIES += opencv_imgcodecs

    endif

endif

---------------------------------------------------------------------------------------------------------------------------------

cp Makefile.config.example Makefile.config

vim Makefile.config

找到下面这两行,再将加黑路径添加上去

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include  /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib  /usr/lib/x86_64-linux-gnu/hdf5/serial

退出vim

make pycaffe

---------------------------------------------------------------------------------------------------------------------------------

这里出错了,提示找不到numpy

执行sudo apt-get install python-numpy

make test

make runtest

添加环境变量

echo 'export PYTHONPATH =$PYTHONPATH:/home/'username'/caffe/python'>>~/.bashrc
source ~/.bashrc

到这里就安装完成了,下面进行测试 

./data/mnist/get_mnist.sh

./examples/mnist/create_mnist.sh

./examples/mnist/train_lenet.sh

./build/tools/caffe.bin test -model=examples/mnist/lenet_train_test.prototxt -weights=examples/mnist/lenet_iter_10000.caffemodel -gpu=0 或者不使用GPU ./build/tools/caffe.bin test -model=examples/mnist/lenet_train_test.prototxt -weights=examples/mnist/lenet_iter_10000.caffemodel

所有数据都训练好之后,接下来就是如何将模型应用到实际数据了。test:表示对训练好的模型进行Testing,而不是training。其他参数包括train, time, device_query。 
-model=XXX:指定模型prototxt文件,这是一个文本文件,详细描述了网络结构和数据集信息。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值