Ubuntu14.04 Build Caffe (CPU only)

Source: Internet
Author: User
Tags using git gfortran

Has not been the habit of blogging, and later found that the previous work if not pay attention to timely collation and records are often lost quickly. For me this is an important article, good habits to persevere, future days I will be resident blog Park! Because this cock level is limited, the IQ is slightly low, welcome big God come to shoot brick. End of nonsense, here is the dry goods:

First of all, I spit a bit of Ben's notebook, my current notebook is still a freshman bought Dell INSPIRON 4010, no nvidia, no NVIDIA, no NVIDIA, no nvidia, important things to say four times, huh.

Operating system: Ubuntu 14.04 uses the Python API: Yes, the target is after installation Caffe can use the hardware as a Python module: low-end notebooks, using only CPU mode

1. Installation dependencies

1 sudo Install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-Compiler  2sudoinstall --no-install-recommends libboost-all-Dev3  sudoinstall libgflags-dev libgoogle-glog-dev liblmdb-Dev4  sudoinstall libatlas-base-de
Python requires version 2.7, which is already installed by the operating system itself. The input python2.7--version will display the specific version number instructions installed. But also requires sudo apt-get install Python-dev

2. Download Caffe
It's very easy to download Caffe using Git, or go to Https://github.com/BVLC/caffe download. Because I used to go to GitHub to find the code, so go directly to the source of the download.

After the download is complete, you will find the caffe-master.zip in the download in your home directory, unzip the home directory with the unzip command, and rename it to Caffe.

3. Compiling Caffe
(1) switch to the directory where Caffe is located

CP Makefile.config.example Makefile.config

(2) Modify the configuration file Makefile.config

    • Cpu_only: = 1
    • Configuration of some reference files (added mainly to address the new version, HDF5 path problem)
Include_dirs: = $ (python_include)  /usr/local/include  /usr/lib/x86_64-linux-gnu/hdf5/serial   Library_dirs:= $ (python_lib)  /usr/local/lib   /usr/lib/usr/lib/x86_64-linux-gnu/hdf5/SerialBLAS: = Atlas
> openlas >atlas

(3) Compiling Caffe

Make makemake runtest 
In addition, this make by default is CPU single core operation, if want a bit faster, for example I want to use four core, add-j4 tag after make. If you want to try again after an error in line 4 above, it is recommended that you make the clean and start again.

4. Compiling the Python interface
The Caffe has a Python\c++\shell interface, which is especially handy in Caffe Python, and has an interface in the instance.

    • Make sure PIP is installed
sudo Install Python-pip
    • 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.

When installing the SCIPY Library, the Fortran compiler (GFORTRAN) is required, and if not, the compiler will get an error, so we can install it first.

First go back to the root directory of Caffe and execute the installation code:

CD ~/Caffesudoinstall  gfortran for a $ (catdo  Install done

After the installation is complete, we can execute:

sudo Install -R python/requirements.txt

You will see that the installation succeeds, the requirement already satisfied is displayed, and the installation will continue without a successful installation.

    • Compiling the Python interface
 make Pycaffe

-the results show that all TESTS passed is installed!

    • Run the python structure
$ python2.7Python2.7. A(Default, Jul1  ., the: A: -) [GCC5.4.0 20160609] on Linux2type" Help","Copyright","credits"Or"License"  for  Moreinformation.>>>Import Caffe>>>

If there is no error, it means Caffe installation is complete!

5. Running Lenet in Mnist

    • Get Data source
./data/mnist/get_mnist. SH . /examples/mnist/create_mnist. SH
    • Because the CPU is running, modify the SOLVER_MODE:CPU in the Lenet_solver.prototxt under mnist under the examples file
Solver_mode:cpu
    • Training model
./examples/mnist/train_lenet. SH

The entire training period lasts for a long time, because this dick's laptop is still a i3 processor, and the GPU is not enabled, and the default is single core, so this cock waits 3 hours. = ..... Automatic Brain repair My heart steeds

6. Finally, my article is based on the predecessors of the great God articles, although according to their process I have been error, but ultimately to help me install success. In order to show respect for the results of others, here are the reference links for the great gods:

Http://www.linuxidc.com/Linux/2016-09/135034.htm

http://blog.csdn.net/u010402483/article/details/51506616

Http://www.cnblogs.com/denny402/p/5679037.html

Ubuntu14.04 Build Caffe (CPU only)

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.