Ubuntu16.04 Caffe CPU version installation steps recorded

Source: Internet
Author: User
Tags jupyter jupyter notebook gfortran

This record is mainly referenced in: Http://blog.csdn.net/yhaolpz 71375762

This record is based on the above reference, modified CPU version Caffe installation steps.

1th Step Installation Caffe

First, under the path you want to install, clone:

clone https://github.com/BVLC/caffe.git

Enter Caffe, copy the Makefile.config.example file and rename it to Makefile.config, or call the following command directly in the Caffe directory to complete the copy operation:

cp Makefile.config.example Makefile.config

The reason for the copy is that the Makefile.config file is required to compile the Caffe, and Makefile.config.example is just an example of the configuration file given by Caffe and cannot be used to compile caffe.

Then modify the Makefile.config file to open the file in the Caffe directory:

sudo gedit Makefile.config

Modify the contents of the Makefile.config file:

1. Application Cudnn

将#USE_CPUONLY := 1修改成:
:= 1

2. Using the Python interface

将#WITH_PYTHON_LAYER := 1 修改为 WITH_PYTHON_LAYER := 1

3. Modify the Python path

:= $(PYTHON_INCLUDE) /usr/local/includeLIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib 修改为: INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serialLIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial 

Then modify the Makefile file in the Caffe directory:

将:LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5改为:LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

OK, you can start compiling and executing in the Caffe directory:

sudo make

This is if the previous configuration or installation error, then the compilation will have a variety of problems, so the previous steps must be careful.

After compiling successfully, you can run the test:

sudo make runtest
2nd Step install Python runtime environment

The first thing you need to do is install the Python usage environment:

Enter the Caffe home directory, CD Caffe, and then execute the Python interface configuration: sudo make Pycaffe

Cxx/ld-o python/caffe/_caffe.so python/caffe/_caffe.cpptouch python/caffe/proto/__init__. Pyprotoc (python) src/caffe/proto/caffe.proto

Then add the Python folder in the Caffe home directory to the BASHRC:

sudo echo export pythonpath="~/caffe/python" >> ~/.bashrc

Update file effective: source ~/.BASHRC

After Python, and then import Caffe, you are prompted with an error:

importerror: No module named skimage. Io

At this point, pip install-u scikit-image can be.

At this point, prompt:

You are using the PIP version 8.1.1, however version 10.0.1 is available.
You should consider upgrading via the ' pip install--upgrade pip ' command.

Follow the PIP install--upgrade pip.

When you are finished installing the command again, it may appear: Importerror:cannot Import name main problem:

Traceback (most recent): File "/usr/bin/pip", line 9, in <module> from pip import main importerror:cannot Import Name Main "

Workaround (quoted from HTTPS://WWW.IMOOC.COM/ARTICLE/31953?BLOCK_ID=TUIJIAN_WZ):
1. In Terminal input:sudo gedit /usr/bin/pip
2. Will:

from pip import mainif __name__ == ‘__main__‘: sys.exit(main())

Switch

from pip import __main__if __name__ == ‘__main__‘: sys.exit(__main__._main())

3. Save the file to exit and complete.

由于我们这里远程服务器配置,因此,没有安装Ipython, 如果需要可按照下述步骤进行安装。

OK, last step, configure notebook environment

To install the Python interface depends on the library, in the Caffe root directory of the Python folder, there is a requirements.txt manifest file, which lists the required dependent libraries, follow this list to install.

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 enter the Caffe/python directory and execute the installation code:

sudo apt-get install gfortranfor req in $(cat requirements.txt); do sudo pip install $req; done

After the installation is complete, execute:

sudo pip install -r requirements.txt

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

Then install Jupyter:

sudo pip install jupyter

When the installation is complete, run notebook:

jupyter notebook 或 ipython notebook

will open the notebook in the browser, click on the upper right corner of the new-python2, you can create a new web-like file, the extension is IPYNB. On this page, we can run the Python code as if it were below the command line.

After entering the code, press Shift+enter to run, more shortcut keys, you can click on the above Help-keyboard shortcuts view, or press ESC to exit the edit state, and then press the H key to view.

 

Ubuntu16.04 Caffe CPU version installation steps recorded

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.