Caffee installation Process
1. Installing dependent Packages
$ 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 libopenblas-dev liblapack-dev libatlas-base-dev$ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
2. Installing Caffe
$ git clone git://github.com/BVLC/caffe.git
3. Compiling Caffe
$ cd caffe$ cp Makefile.config.example Makefile.config (复制一份Makefile.config文件)
In the Makefile.config file, the cpu_only: = 1 Comment is removed, is to remove the previous # number
Next, execute the following command under the Caffe root directory
$ make all
After this command, I encountered an error message,
./include/caffe/util/hdf5.hpp:6:18: fatal error: hdf5.h: No such file or directory
This is caused by the HDF5 path problem, you can obtain the path of HDF5 by the following command,
The path I found for the hdf5.h is:/usr/include/hdf5/serial/hdf5.h, so in the Makefile.config file, change the file to the following:
Again to execute the above command, continue to error, this time is/usr/bin/ld:cannot Find-lhdf5 then with the above one processing to find the libhdf5.so configuration file instead:
Library_dirs: = $ (python_lib)/usr/lib/x86_64-linux-gnu/hdf5/serial
? /usr/local/lib/usr/lib
Include_dirs: = $ (python_include)/usr/include/hdf5/serial
? /usr/local/include
/usr/bin/ld:cannot Find-lcblas/usr/bin/ld:cannot Find-latlas
Solve
sudo apt-get install libatlas-base-dev
Then execute the following command:
make test
At last
$ make runtest
4. Compiling the Python interface
Install PIP
$ sudo apt-get install python-pip
Performing the installation depends on the manifest installation listed in Requirements.txt in the Caffe/python directory. The Fortran compiler (GFORTRAN) makes an error in order to install scipy.
cd ~/caffesudo apt-get install gfortrancd ./pythonfor req in $(cat requirements.txt); do pip install $req; done
Back to Caffe root directory
sudo pip install -r python/requirements.txt
Compiling the Pycaffe interface
make pycaffe -j81
Error at this time
python/caffe/_caffe.cpp:10:31: fatal error: numpy/arrayobject.h: 没有那个文件或目录12
Then, enter the following command to
sudo apt-get install python-numpy
import syssys.path.append("/(你的caffe路径)/caffe/python")sys.path.append("/(你的caffe路径)/caffe/python/caffe")
PS: Permanently add python path:
cd /usr/lib/python2.7/dist-packages sudo echo mycaffe.pth #建立一个mycaffe.pth文件sudo gedit mycaffe.pth #编辑文件
Start Python2 Import Caffe
Error: Importerror:no module named Skimage.io
Solve:
sudo apt-get install python-skimage
Error: Importerror:no module named google.protobuf.internal
conda install protobuf
There is still no solution:
Then look for:
sudo apt-get install python-protobuf
It worked!
Next start the test:
Mnist Data Set Acquisition:
sudo sh ./data/mnist/get_mnist.shsudo sh ./examples/mnist/create_mnist.sh
2. Modify the configuration
Modify the Prototxt extension profile modification under this directory./examples/mnist/lenet_solver.prototxt navigates to the last line: Solver_mode:gpu, changes the GPU to CPU. Testing with the CPU
3. Run the Execute File command:
sudo sh ./examples/mnist/train_lenet.sh
Error:./train_lenet.sh:4:./train_lenet.sh:./build/tools/caffe:not found
Re-compiling
sudo make all
Display: Nothing-to-be-do for all
The final trained model is stored as a binary protobuf file:./examples/mnist/lenet_iter_10000.caffemodel
This model can be used to directly use the
Suddenly you can use the ...
Re-execute
sudo sh ./examples/mnist/train_lenet.sh
It's best to add time to see how long it takes
Happy, fortunately, the CPU version, 1.1 points to solve the problem
Main Reference Blog:
Blog 1
Blog 2
Caffe CPU version Linux configuration command and build