Copyright statement: This article is the original article of the blogger and may not be reproduced without the permission of the blogger. https://blog.csdn.net/qq_25737169/article/details/77773884
This content is from the Linux Commune. There are still some problems with the installation according to the original tutorial, which are solved here.
Part 1: Install dependencies
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
PYTHON requires version 2.7, which is already installed by the operating system itself. Enter python2.7 --version and the specific version number will be displayed indicating that it is installed.
But you also need sudo apt-get install python-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
( It doesn't matter what folder all the above sudo apt-get enters.)
Then download the source code of CAFFE: git clone https://github.com/BVLC/caffe.git
( (Of course, if you don't have GIT installed, you must install it first)
After the download is complete, use the cd command in the command line, for example, $cd ./caffe/python, enter the caffe folder, enter the python folder inside, and then enter the following code in the command line, and enter the semicolon.
for req in (cat requirements.txt); do pip install $req; done
( If PIP is not installed, install it first: sudo apt install python-pip)
Part 2: Install CAFFE
Go to the CAFFE folder and use the template to write a Makefile.config. Specifically, copy Makefile.config.example and rename it to Makefile.config
cp Makefile.config.example Makefile.config
Because of CPU MODE, the # in front of CPU_ONLY := 1 should be removed.
The two paths should be changed to this: (add the following two hdf5 paths, otherwise hdf5 errors will be reported during compilation)
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
Ready.
make pycaffe
make all
make test
make runtest
-The result shows that ALL TESTS PASSED is installed, just add a PYTHONPATH;
In addition, this make uses single-core CPU operation by default. If you want to be faster, for example, I want to use quad-core, add the -j4 tag after make.
If you want to try again after reporting an error in one of the above 4 lines, it is recommended to make clean first and then start again.
Compilation takes time,
Part 3: Setting up Python Caffe
Go to the python folder in the CAFFE folder and record the current path (pwd). Then enter the following command (put the recorded path in the corresponding place)
export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH
At this time it should be fine, try it out:
$ python2.7
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
[ GCC 5.4.0 20160609] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
import caffe
caffe.version
Press Enter to view the version of caffe
The installation is complete!
Note: The previous export operation is only temporary, if you encounter import caffe failure to reopen the command window. When prompted that there is no model of caffe, you need to set environment variables and enter in the command line
export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH
/path/to/caffe/python is the python folder path under the folder where you installed caffe, sudo vim /etc/profile If you don’t have vim, you can also use sudo gedit /etc/profile and then add this sentence
export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH add it to the opened file,
/path/to/caffe/python is the python folder path under the folder where you installed caffe,
Finally, run a command: source profile is complete, import caffe again without error
Part 4: Errors
Basically all errors are due to the lack of dependencies or the wrong path, so the medicine is prescribed according to the specific error information. For example:
The hdf5 error is displayed during compilation. According to the above, it is resolved after adding the path.
When import caffe shows scikit-image error, just install scikit-image.
pip install scikit-image
Many people have encountered various errors when installing CAFFE. Please be patient and Google more. It will be done.
Matlab2014a+Anaconda2+OpenCV3.1+Caffe installation under Ubuntu 16.04http://www.linuxidc.com/Linux/2016-07/132860.htm
CUDA7.5 configuration Caffe tutorial under Ubuntu 16.04 system http://www.linuxidc.com/Linux/2016-07/132859.htm
Caffe installation under Ubuntu 14.04 64bit http://www.linuxidc.com/Linux/2015-07/120449.htm
The deep learning framework Caffe is compiled and installed under Ubuntu http://www.linuxidc.com/Linux/2016-07/133225.htm
Caffe + Ubuntu 14.04 64bit + CUDA 6.5 configuration instructions http://www.linuxidc.com/Linux/2015-04/116444.htm
Install Caffe on Ubuntu 16.04 http://www.linuxidc.com/Linux/2016-08/134585.htm
Caffe configuration concise tutorial (Ubuntu 14.04 / CUDA 7.5 / cuDNN 5.1 / OpenCV 3.1) http://www.linuxidc.com/Linux/2016-09/135016.htm
Recommended Posts