Ubuntu 16.04 + Caffe Environment Setup (CPU)

Source: Internet
Author: User

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
    • Because the CPU is running, modify the Lenet.prototxt under mnist under the examples file solver_mode:cpu
    • Training model

      ./examples/mnist/train_lenet.sh

      The training is completed as follows (i5-7200u 18 minutes or so):

      Above

Ubuntu 16.04 + Caffe Environment Setup (CPU)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.