1. Installation dependencies
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compilersudo apt-get install --no-install-recommends libboost-all-devsudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-devsudo apt-get install libatlas-base-dev
Note: It is important to make sure that each is installed, there is no error, or there will be problems later.
2. Installing Python-dev
sudo apt-get install python-dev
3. Download Caffe
Go directly to the website (Https://github.com/BVLC/caffe
) Download and unzip to the/home/usr_name/directory
4. Compiling Caffe
4.1 switch to the Caffe directory you just unzipped
cp Makefile.config.example Makefile.config
4.2 Modifying a configuration file Makefile.config
- Cpu_only: = 1
- 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
Note: (Here is to add a section primarily to solve the new version of the HDF5 path problem) Notice the underscore and minus sign
4.3 compiling
sudo make all sudo make testsudo make runtest
Note: The default is a single-core run, you can add a -j4
4-core in the back, indicating success
5. Compiling the Python interface
Make sure Python-pip and Python-numpy are installed
Performing installation dependencies
Under the Python folder in the Caffe root directory, there is a requirements.txt manifest file, which lists the required libraries, which are installed as per the list.
First go back to Caffe's home directory
sudo apt-get install gfortrancd ./pythonsudo cat python/requirements.txt|xargs -L 1 sudo pip install
Once the installation is complete, go back to the Cafffe root directory and we can execute:
sudo pip install -r python/requirements.txt
You will see that the successful compilation will show requirement already satisfied, and the installation will continue without a successful compilation.
Compiling the Python interface
sudo make pycaffe
After compiling, run the python structure, go to Caffe/python and execute the command, otherwise you will not be prompted to find Caffe
6. Running Lenet in Mnist
- Get Data source
sudo ./data/mnist/get_mnist.shsudo ./examples/mnist/create_mnist.sh
Ubuntu 16.04 + Caffe Environment Setup (CPU)