【歸檔】Ubuntu16.04 配置 caffe

配置環境

Ubuntu 16.04

安裝依賴

$ 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
$ sudo apt-get install libopencv-dev

編譯Caffe

$ git clone https://github.com/intel/caffe.git
$ cd caffe/
$ cp Makefile.config.example Makefile.config
$ vim Makefile.config
# 修改
# INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
# LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
# 爲
# 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 /usr/lib/x86_64-linux-gnu/hdf5/serial
# 保存並退出
$ make all -j4
# 編譯ing...

使用Caffe訓練和測試(在caffe目錄下)

# 獲取mnist數據集,並轉換爲lmdb數據格式
$ ./data/mnist/get_mnist.sh
$ ./examples/mnist/create_mnist.sh
# 訓練 
$ ./build/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt
$ ls examples/mnist/
# *.caffemodel 生成模型
# 使用測試集檢驗
$ ./build/tools/caffe test -model examples/mnist/lenet_train_test.prototxt -weights examples/mnist/lenet_iter_10000.caffemodel -iterations 100
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章