Caffe no GPU environment to build

Source: Internet
Author: User
Tags jupyter jupyter notebook gfortran

[Email protected]:/home/k# sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev Libopencv-dev Libhdf5-serial-dev Protobuf-compiler
[Email protected]:/home/k# sudo apt-get install--no-install-recommends Libboost-all-dev

[Email protected]:~# sudo apt-get install linux-headers-$ (uname-r)

BLAS

[Email protected]:/home/k# sudo apt-get install Libatlas-base-dev

Other dependencies

OpenCV

[Email protected]:/home/k# sudo apt-get install build-essential

[Email protected]:/home/k# sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev Libtiff -dev Libjasper-dev Libdc1394-22-dev

1234 git clone HTTPS://github. com/itseez/opencv. Git cd ~/ OpenCV mkdir build cd build

[Email protected]:~/opencv/build# cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local  .

[Email protected]:~/opencv/build# ls3rdparty               cpacksourceconfig.cmake  Makefileapps                   Ctesttestfile.cmake      modulesbin                    custom_hal.hpp           opencv2CMakeCache.txt         cvconfig.h               Opencvconfig.cmakecmakefiles             data                     opencvconfig-version.cmakecmake_install.cmake    Doc                      OpenCVModules.cmakecmake_uninstall.cmake  include                  test-reportscmakevars.txt          junk                     Unix-installcpackconfig.cmake      Lib                      version_string.tmp

[Email protected]:~/opencv/build# make-j4

[Email protected]:~/opencv/build#  sudo make install

Caffe

[Email protected]:~/caffe# lscaffe.cloc       data      install.md               models     toolscmake            Docker    LICENSE                  pythonCMakeLists.txt   docs      Makefile                 README.mdCONTRIBUTING.md  examples  Makefile.config.example  scriptscontributors.md  include   matlab                   src[email protected]:~/caffe# Pwd/root/caffe[email protected]:~/caffe# CP Makefile.config.example Makefile

[Email protected]:~/caffe# vim Makefile

Endififeq ($ (USE_OPENCV), 1)        LIBRARIES + = Opencv_core Opencv_highgui opencv_imgproc opencv_imgcodecs #增加opencv_ Imgcodecs         ifeq ($ (opencv_version), 3)                LIBRARIES + = Opencv_imgcodecs        endif

[Email protected]:~/caffe# make all

[Email protected]:~/caffe# make allcxx Src/caffe/common.cppin file included from./include/caffe/common.hpp:19:0,                 From src/caffe/common.cpp:7:./include/caffe/util/device_alternate.hpp:34:23:fatal error:cublas_v2.h:no such file or Directory #include <cublas_v2.h>                       ^compilation terminated.make: * * * [. BUILD_RELEASE/SRC/CAFFE/COMMON.O] Error 1

[Email protected]:~/caffe# VI makefile.config
# cpu-only switch (uncomment to build without GPU support).
Cpu_only: = 1 #关键

[Email protected]:~/caffe# make all

[Email protected]:~/caffe# make test

[Email protected]:~/caffe# make runtest

[Email protected]:~/caffe# make runtest.build_release/tools/caffe.build_release/tools/caffe:error while loading Shared Libraries:libopencv_core.so.3.1:cannot open Shared object file:no such file or directorymake: * * * [runtest] Erro R 127

[Email protected]:~/caffe# export ld_library_path= $LD _library_path:/usr/local/lib

[Email protected]:~/caffe# make runtest
... [----------] 1 test from SOLVERTEST/1, where typeparam = caffe::cpudevice<double>[RUN ] SOLVERTEST/1. testinittraintestnets[ OK] solvertest/1.testinittraintestnets (1 ms) [----------] 1 Test from SOLVERTEST/1 (1 ms Tota L) [----------] 2 tests from EUCLIDEANLOSSLAYERTEST/1, where typeparam = caffe::cpudevice<double>[RUN ] euclideanlosslayertest/1.testgradient[ OK] euclideanlosslayertest/1.testgradient (0 ms) [RUN ] euclideanlosslayertest/1.testforward[ OK] Euclideanlosslayertest/1.testforward (0 ms) [----------] 2 tests from EUCLIDEANLOSSLAYERTEST/1 (0 ms total) [----------] Global test environment tear-down[==========] 1054 tests from 146 test C ASEs ran. (37419 MS Total) [ PASSED ] 1054 tests.

Install Python and Pip

[Email protected]:~/caffe# python--versionpython 2.7.6

PIP is specifically used to install Python's various dependent libraries, so we'll install pip1.5.6 here http://pan.baidu.com/s/1cfsHv4

[Email protected]:~# wget  https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz--2016-05-03 14:40:36 --  https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gzResolving pypi.python.org (pypi.python.org) ... 103.245.224.223Connecting to Pypi.python.org (pypi.python.org) |103.245.224.223|:443 ... Connected. HTTP request sent, awaiting response ... oklength:938120 (916K) [application/octet-stream]saving to: ' Pip-1.5.6.tar.gz ' 100%[============================ =======================>] 938,120      294kb/s in   3.1s   2016-05-03 14:40:40 (294 kb/s)-' pip-1.5.6.tar.gz ' Saved [938120/938120]

[Email protected]:~# cd pip-1.5.6[email protected]:~/pip-1.5.6# lsAUTHORS.txt  docs         manifest.in  Pip.egg-info  PROJECT.txt  setup.cfgCHANGES.txt  LICENSE.txt  pip          pkg-info      readme.rst   setup.py

[email protected]:~/pip-1.5.6# sudo python setup.py installtraceback (most recent call last):  File ' setup.py ', line 6 , in <module> from    setuptools import Setup, Find_packagesimporterror:no module named Setuptools

Some computers may be prompted for no moudle name Setuptools error, which is why the Setuptools is not installed. Then you need to install Setuptools to https://pypi.python.org/packages/source/s/setuptools/setuptools-19.2.tar.gz. Download the installation package setuptools-19.2.tar.gz, then unzip the execution

Http://pan.baidu.com/s/1dFx31Ax

[Email protected]:~# wget https://pypi.python.org/packages/source/s/setuptools/setuptools-19.2.tar.gz--2016-05-03 14:44:07--  https://pypi.python.org/packages/source/s/setuptools/setuptools-19.2.tar.gzResolving pypi.python.org (pypi.python.org) ... 103.245.224.223Connecting to Pypi.python.org (pypi.python.org) |103.245.224.223|:443 ... Connected. HTTP request sent, awaiting response ... oklength:641777 (627K) [application/octet-stream]saving to: ' Setuptools-19.2.tar.gz ' 100%[====================== =============================>] 641,777      287kb/s in   2.2s   2016-05-03 14:44:11 (287 kb/s)-' Setuptools-19.2.tar.gz ' saved [641777/641777]

[Email protected]:~# lscaffe      opencv      pip-1.5.6         setuptools-19.2caffe.tar  Opencv.tar  pip-1.5.6.tar.gz  setuptools-19.2.tar.gz[email protected]:~# cd setuptools-19.2[email protected]:~/ setuptools-19.2# lsbootstrap.py     ez_setup.py  msvc-build-launcher.cmd  release.py  Setuptools.egg-infochanges.txt      launcher.c   pkg-info                 scripts     testsconftest.py      Makefile     pkg_resources            setup.cfg   tox.inidocs             manifest.in  pytest.ini               setup.pyeasy_ install.py  _markerlib   README.txt               setuptools

[email protected]:~/setuptools-19.2# sudo python setup.py install

[Email protected]:~# cd pip-1.5.6[email protected]:~/pip-1.5.6# sudo python setup.py install

Install the Pyhon 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 go back to the root directory of Caffe and execute the installation code:

[Email protected]:~/pip-1.5.6# cd ~/caffe[email protected]:~/caffe# sudo apt-get install Gfortran

[Email protected]:~/caffe# cd python/[email protected]:~/caffe/python# lscaffe  classify.py  CMakeLists.txt  detect.py  draw_net.py  requirements.txt[email protected]:~/caffe/python# for req in $ (cat Requirements.txt); Do sudo pip install $req; Done

[Email protected]:~/caffe/python# CD. [Email protected]:~/caffe# lsbuild            contributors.md  examples    makefile.config          README.mdcaffe.cloc       data             include     Makefile.config.example  scriptscmake            distribute       install.md  matlab                   srcCMakeLists.txt   Docker           LICENSE     models                   toolscontributing.md  docs             Makefile    python[email protected]:~/caffe# sudo pip install-r python/requirements.txt

Compiling the Python interface first, add the Python folder under the Caffe root directory to the environment variable to open the configuration file BASHRC

[Email protected]:~/caffe# sudo vi ~/.bashrc

Export Pythonpath=/root/caffe/python: $PYTHONPATH  #追加到最后

[Email protected]:~/caffe/python# sudo ldconfig

[Email protected]:~/caffe# sudo make Pycaffe
Cxx/ld-o python/caffe/_caffe.so Python/caffe/_caffe.cpp
Touch python/caffe/proto/__init__.py
Protoc (python) Src/caffe/proto/caffe.proto

View python/caffe/directory, in addition to the original bunch of py suffix files, now more than a bunch of pyc suffix file

/root/caffe/python/caffe[email protected]:~/caffe/python/caffe# CD. [email protected]:~/caffe/python# Lscaffe classify.py CMakeLists.txt detect.py draw_net.py Requirements.txt[ema il protected]:~/caffe/python# Pythonpython 2.7.6 (default, June, 17:58:13) [GCC 4.8.2] on Linux2type "Help", " Copyright "," credits "or" license "for more information.>>> import caffecaffe/pycaffe.py:13:runtimewarning: To-python Converter for boost::shared_ptr<caffe::net<float> > already registered;  Second conversion method ignored. From. _caffe import Net, Sgdsolver, Nesterovsolver, Adagradsolver, Caffe/pycaffe.py:13:runtimewarning:to-python Converter for boost::shared_ptr<caffe::blob<float> > already registered;  Second conversion method ignored. From. _caffe import Net, Sgdsolver, Nesterovsolver, Adagradsolver, Caffe/pycaffe.py:13:runtimewarning:to-python Converter for boost::shared_ptr<caffe::solver<float> > already registered; SEcond conversion method ignored. From. _caffe import Net, Sgdsolver, Nesterovsolver, Adagradsolver,/usr/local/lib/python2.7/dist-packages/matplotlib/ Font_manager.py:273:userwarning:matplotlib is building the font cache using Fc-list.  This could take a moment. Warnings.warn (' matplotlib is building the font cache using Fc-list. This could take a moment. ')  >>>

[Email protected]:~/caffe/python# cd caffe/[email protected]:~/caffe/python/caffe# ls_caffe.cpp     classifier.pyc  detector.pyc  __init__.py   io.pyc        proto        test_caffe.so      coord_map.py    draw.py       __ Init__.pyc  net_spec.py   pycaffe.pyclassifier.py  detector.py     imagenet      io.py         net_ SPEC.PYC  PYCAFFE.PYC

Installing Jupyter

Learn python not yet, you have to learn Ipython, the latter more convenient and fast, more automatic completion function. And Ipython notebook is the best way to show Ipython. The latest version is renamed Jupyter notebook, let's install it first.

[Email protected]:~/caffe/python# sudo pip install Jupyter

After the installation is successful, run the Notebook

[Email protected]:~/caffe/python# jupyter Notebook

Caffe no GPU environment to build

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.