I wanted to use Caffe, a library with a good reputation for image recognition, I tried to summarize the procedure to install and run the sample (mnist).
The setup environment is as follows.
Install the required set of libraries.
~
$ sudo apt-get install libatlas-base-dev libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler git
Download the Caffe source from git.
~
$ git clone https://github.com/BVLC/caffe.git
$ cd caffe
First, create a make file for compilation.
caffe/
$ cp Makefile.config.example Makefile.config
If you compile as it is, some errors occurred, so To avoid that, rewrite some configuration files.
If you are told something like "can't find hdf5.h" First, let's check if libhdf5-dev is apt-get.
If it's installed but you get an error, Modify INCLUDE_DIRS in Makefile.config.
caffe/Makefile.config
#INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
Next, if you are told "/ usr / local / cuda / bin / nvcc: not found", Modify CUDA_DIR in Makefile.config.
caffe/Makefile.config
#CUDA_DIR := /usr/local/cuda
CUDA_DIR := /usr
If you get an error around memcpy, modify NVCCFLAGS in caffe / Makefile as follows. (Not Makefile.config, confusing)
caffe/Makefile
#NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
When you are told "/ usr / bin / ld: -hdf5_hl not found" Paste the symbolic link inside / usr / lib / x86_64-linux-gnu.
/usr/lib/x86_64-linux-gnu
$ cd /usr/lib/x86_64-linux-gnu
$ sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so
$ sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so
At this point, the necessary settings should be almost complete. Let's compile and test.
caffe
$ make
$ make runtest
If the runtest result is PASSED, the Caffe installation is complete.
By default, caffe contains a set of learning scripts.
So, after that, you can move the sample just by hitting the script one by one.
First, download the mnist data and convert it.
caffe/
$ data/mnist/get_mnist.sh
$ examples/mnist/create_mnist.sh
Now that we have the training data, let's train the model.
caffe/
$ examples/mnist/train_lenet.sh
Finally, run the mnist test using the trained model.
caffe/
$ ./build/tools/caffe test -model ./examples/mnist/let_train_test.prototxt -weights ./examples/mnist/lenet_iter_10000.caffemodel
Up to this point, I was able to move Caffe.
Recommended Posts