Caffe + ubuntu16.04 (version without GPU)

Source: Internet
Author: User
Tags cuda toolkit

This are based on Caffe GitHub Wiki Guide (https://github.com/BVLC/caffe/wiki/ Ubuntu-16.04-or-15.10-installation-guide)

Some parts of it has been changed to suit my computer.

  

The following guide includes the how-to instructions for the installation of Bvlc/caffe in Ubuntu 16.04 (preliminary proce Dure does not function with the current Cuda Toolkit) or 15.10 Linux (works well). This also includes the Kubuntu 16.04 or 15.10 and the related distributions.

Execute these commands first:

sudo apt-get updatesudo apt-get upgradesudo apt-get install-y build-essential cmake git pkg-configsudo apt-get install-y Libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compilersudo apt-get install-y Libatlas-base-dev sudo apt-get install-y--no-install-recommends libboost-all-devsudo apt-get install-y libgflags-dev L Ibgoogle-glog-dev Liblmdb-dev# (python general) sudo apt-get install-y python-pip# (Python 2.7 development files) sudo apt-get install-y python-devsudo apt-get install-y python-numpy python-scipy

I didn ' t try Python 3.5 to avoid a version confilct problem, and I also didn ' t use OPENCV 3.1 for the same reason.
I just want to make it simple and function well.
# (OpenCV 2.4) sudo apt-get install-y Libopencv-dev

Go to the Https://github.com/BVLC/caffe and download zip archive. Unpack it to ~/bin/or any other location. Enter the Caffe-master directory in the terminal window.

Copy the Makefile.config.example to makefile.config like this:

cp Makefile.config.example Makefile.config

and open it for editing (with a text editor). I use the Kate Editor for this purpose, and the command that I execute goes as follows. You first need to install the Kate Editor with:

sudo apt-get install kate

And then your can edit the configuration file with:

kate ./Makefile.config &

The following line in the configuration file tells the "program" is the only CPU that is for the computations.

Cpu_only: = 1

The typical setting for a computer without any NVIDIA graphics card and it's typical for the installation of Caff E inside the typical virtual machine. (Notice that there was a special type of virtual machine inside the Ubuntu host machine that can access the physical NVIDIA Graphics card directly. See Https://github.com/NVIDIA/nvidia-docker)

Change of the line accordingly by commenting it off (# cpu_only: = 1) If you have a NVIDIA graphics card with the Proprietar Y driver, CUDA Toolkit and CUDNN installed. The makefile.config should contain the following lines, so find them and fill them in.

Python_include: =/usr/include/python2.7/usr/lib/python2.7/dist-packages/numpy/core/include

(For ways to create a isolated Python environment, explore the topic of virtual Environments Here:http://docs.python-gui de.org/en/latest/dev/virtualenvs/)

With_python_layer: = 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/usr/lib/x86_64-linux-gnu/hdf5/ Serial

Now lets continue with the instructions for version 15.10 First, followed by instructions for 16.04 users.

Execute the additional commands:

find . -type f -exec sed -i -e ‘s^"hdf5.h"^"hdf5/serial/hdf5.h"^g‘ -e ‘s^"hdf5_hl.h"^"hdf5/serial/hdf5_hl.h"^g‘ ‘{}‘ \;cd /usr/lib/x86_64-linux-gnusudo ln -s libhdf5_serial.so.8.0.2 libhdf5.sosudo ln -s libhdf5_serial_hl.so.8.0.2 libhdf5_hl.so

The above commands would need to being executed for Ubuntu 16.04 as well, and the file versions for libhdf5_serial.so and libhdf5_serial_h1.so is different and so the last of the lines would need to be altered. Visit/usr/lib/x86_64-linux-gnu/and list the relevant contents of that directory using a command

such asls | grep hdf5

The versions of LIBHDF5, need to being linked to is 10.1.0 and 10.0.2 respectively.

So, for Ubuntu16.04, execute the additional commands like this:

  find . -type f -exec sed -i -e ‘s^"hdf5.h"^"hdf5/serial/hdf5.h"^g‘ -e ‘s^"hdf5_hl.h"^"hdf5/serial/hdf5_hl.h"^g‘ ‘{}‘ \;

  cd /usr/lib/x86_64-linux-gnu

such asls | grep hdf5

  sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so

  sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so

     

Now for both platforms lets return to the unpacked Caffe directory Caffe-master and enter these commands:

cd pythonfor req in $(cat requirements.txt); do pip install $req; done

Note:if the Ubuntu operating system is updated, perhaps the Python layer needs to be updated and recompiled, because the Python module no longer works. Perform This step again in the case.

for req in $(cat requirements.txt); do pip install $req; doneIn case of any problems, try:for req in $(cat requirements.txt); do sudo -H pip install $req --upgrade; done

The build process would fail in Ubuntu 16.05 due to the GCC 5.x compiler when compiling Cuda 7.5 sources. The updated version of Cuda Toolkit 8.0RC is compatible with GCC 5.x compiler in Ubuntu 16.05. Once Cuda Toolkit 8.0RC is installed, Caffe would successfully build and run in Ubuntu 16.05.

The next step is to execute the following code to build Caffe:

cd ..(now you are in caffe-master directory)make allmake testmake runtestmake pycaffe      -should be finished already, so you can omit this onemake distribute

Note that the build process can be sped up by Appending-j $ (($ (Nproc) + 1) to the above commands, which distributes the Build across the available processors on your system. For example:

make all

can become

make all -j $(($(nproc) + 1))

In order to make the Python work with Caffe, open the file ~/.bashrc for editing in your favorite text editor. There, add the following line at the end of file:

Export Pythonpath=/path/to/caffe-master/python: $PYTHONPATH

You can also execute this same line immediately as a command for immediate effects.

Caffe + ubuntu16.04 (version without GPU)

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.