52263711
Learning to use the framework of deep learning, the need to build Caffe, Theano and torch framework. After one months of unremitting struggle, finally set up the framework. Now share the simple build process, save time for the students to use the deep learning framework later, write this blog. Because there are a variety of problems with the framing process, there are hundreds of combinations of different hardware (such as laptops, desktops), different software (such as libraries, compilers), and versions of the software (such as compiler versions, which do not find a dependent library path when compiling the framework), and problems in the network may be the same as in your case. But the solution is not to solve your problem. Therefore, to have more patience Baidu, Google to try to solve the method, will be able to solve the (time-consuming, very pit, but a lot of harvest 233), the tutorial is for reference only. Bo Master is swimming to the shore of the road, if there are errors also please Haihan, learn together! Online a lot of blog has written how to build a tutorial, because the process of building reference to a lot of blogs and official tutorials, so write your own in the notebook to build the tutorial bar, suitable for any time in their own this adjustment program of small partners. First of all, my notebook model: ASUS U303L, graphics card nvidia gt840m (seemingly does not support cudnn acceleration), other detailed configuration please search online. The first part of the system installation version Ubuntu16.04. The installation process is omitted here, please search the installation process on your own website. The second part of the graphics driver and the installation of the CUDA8.0RC 1, graphics driver installation I am here to use the latest PPA update driver, can be used to get a very good experience, and can realize the free switching of dual graphics card. First, open the terminal via the shortcut key ctrl+alt+t and then join the official PPA Source:
$ sudo add-apt-repository ppa:graphics-drivers/ppa
You need to enter a user password and confirm the link source. After you refresh the software library and install the latest driver, enter it at the command line:
$ sudo apt-get update
Then open Ubuntu system Settings-"software and Updates-" Additional drivers, select the latest version of the video card installed driver, the system will automatically install the video card driver, and then reboot the system will switch to a single display. Many of the internet is downloading the official graphics driver is easy to install after the installation can not log on the system, login interface dead loop, or restart the black screen. So this method is recommended. After successful installation, the following commands can be viewed: (due to space, omitted)
$ nvidia-settings
2, CUDA8.0RC installation and configuration CUDA8.0RC download please go to the official website to download, it is recommended to download runfile (local) type, download to do MD5 check, to ensure that the installation package is not a problem. Tools used in the rear: (Vim Installation: terminal input $ sudo apt-get install vim) Then, exit the GUI, i.e. the X-win interface, by pressing: CTRL+ALT+F1 (F2-F6) and switching to tty1-6 command line mode. Log on to the root user and turn off desktop services:
# service lightdm stop
Then enter the following command:
# vim /etc/modprobe.d/blacklist.conf
On the last side of the file, add this sentence:
blacklist nouveau
Reboot, then enter TTY1, log in to the root user:
- # chmod +x Cuda*.run #获取文件权限
- #./cuda*.run #执行文件安装
Be sure not to install the Nvidia driver again during the selection process, otherwise the previously installed graphics drivers will be broken. Special Note: All the compilations here are compiled with Ubuntu with the compiler gcc and g++ versions, do not downgrade, will not cause the subsequent compilation Caffe the failure to find a dependent library error. Wait for Cuda installation to complete. To configure environment variables:
# vim /etc/profile
Add this sentence at the end of the file:
- Path=/usr/local/cuda/bin: $PATH
- Export PATH
Save exit, press ESC, and then enter ": Wq". Enter the command:
# source /etc/profile
Make it effective enter the command:
# vim /etc/ld.so.conf.d/cuda.conf
Add Content:
/usr/local/cuda/lib64
Enter the command:
# ldconfig
Make it effective cuda verify that the test Cuda is installed successfully:
# cd /usr/local/cuda/samples
Compilation Example:
# make all -j2 (我的本本是双核CPU,所以-j2都用上加快编译速度)
Run the compiled executable result file, CD to/usr/local/cuda/samples/x86_64/linux/release, enter:
# ./deviceQuery
Final Test through the third part of the OpenCV3.1.0 installation and configuration first install the necessary libraries, and some rely on the library I have been installed, the specific installation of the relationship has been forgotten. If some dependencies do not meet the error, you can install the library again:
- $ sudo apt-get-y remove ffmpeg x264 libx264-dev
- $ sudo apt-get-y install Libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev Libjas Per-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev Libgstreamer0.10-dev Libgstreamer-plugins-base0.10-dev libv4l-dev x264 v4l-utils ffmpeg Libgtk2.0-dev
Download the OpenCV3.1.0 version according to the link on the official website and unzip it and then go to the installation file directory:
- $ mkdir OpenCV
- $ CD OpenCV
Build the build directory that you want to compile, and then go to the build directory to compile:
- $ mkdir Build
- $ CD Build
- $ cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local-d with_tbb=on-d build_new_python_support=on-d W ith_v4l=on-d install_c_examples=on-d install_python_examples=on-d build_examples=on-d with_qt=on-d WITH_OPENGL=ON.
During the Configure process, you may receive the following error: Icv:downloading ippicv_linux_20151201.tgz ... In the process of downloading the file directly, it will fail due to timeout, can download ippicv_linux_20151201.tgz, and replace opencv-3.1.0/3rdparty/ippicv/downloads/ linux-8b449a536a2157bcad08a2b9f266828b file under the same name, and then CMake again. After generating the compiled file, in the Opencv-3.1.0/build directory, terminal input:
- $ make-j2
- $ sudo make install
Install the environment variables in the future to make them effective:
- $ sudo sh-c ' echo '/usr/local/lib ' >/etc/ld.so.conf.d/opencv.conf '
- $ sudo ldconfig
Special Note: All the compilations here are compiled with Ubuntu with the compiler gcc and g++ versions, do not downgrade, will not cause the subsequent compilation Caffe the failure to find a dependent library error. Trying to build v3.1 OpenCV with Cuda support may appear while waiting for the installation to finish compiling opencv3.1.0. Standard CMake. Project Of:opencv_cudalegacy not compile--Nppigraphcut missing error, the workaround is as follows: Try This:in graphcuts.cpp (where your error I s thrown) Change this:
- #include "precomp.hpp"
- #if!defined (Have_cuda) | | Defined (Cuda_disabler)
To this:
- #include "precomp.hpp"
- #if!defined (Have_cuda) | | Defined (Cuda_disabler) | | (cudart_version >= 8000)
Because Graphcuts is not a supported directly with CUDA8 anymore. Part IV python Installation and debugging Python installation in two ways: one is the system comes with Python, only need to install the corresponding library, the second is to install Anaconda directly, many of the corresponding libraries are already included. The First Direct installation library file is simple and does not need to modify the corresponding include path and library file. The first is as follows, and the second (slightly): The first installation of PIP,PIP with the following command is a Python tool for installing and managing an extension library.
$ sudo apt-get install python-pip
After the installation is complete, enter the Ipython command to test if it starts properly. To make Ipython notebook work, you will also need to install Tornado and PYZMQ:
- $ sudo pip install Tornado PYZMQ pygments
- $ sudo apt-get install Libzmq-dev
Using the Ipyhthon NoteBook (browser-based Python IDE), especially for teachers who need to do tutorials with Python, you can export. py,. IPYNB, HTML format with the following installation steps:
$ sudo ipython notebook
Start (auto Open browser): $ Ipython Nootbook You can quickly install these libraries by Apt-get command:
$ sudo apt-get install python-numpy python-scipy python-matplotlib python-qt4 qt4-designer pyqt4-dev-tools python-qt4-doc spyder cython swig python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags ipython protobuf-c-compiler protobuf-compiler
Part V installation and configuration of Caffe first, install the Caffe necessary library files:
- $ sudo apt-get update
- $ sudo apt-get install build-essential cmake git pkg-config libprotobuf-dev libleveldb-dev Libsnappy-dev Libopencv-dev Lib Hdf5-serial-dev protobuf-compiler Libgflags-dev Libgoogle-glog-dev liblmdb-dev Python-dev
- $ sudo apt-get install--no-install-recommends Libboost-all-dev
After executing the above statement, the basic dependent library installs the Blas, installs the Blas automatically with the following statement (of course, you can choose another library), execute:
$ sudo apt-get install libatlas-base-dev
To modify the configuration file, go to the root directory of Caffe and execute:
$ cp Makefile.config.example Makefile.config
Open Makefile.config to modify it, makefile.config modify content as follows (not Configured CUDNN acceleration):
- <pre name="code" class="html" > comment on line 5th of use_cudnn: = 1
- Remove Opencv_version from the 21st line of comments: = 3
Add path
- Add/usr/include/usr/include/hdf5/serial after Include_dirs: = $ (python_include)/usr/local/include
- Add/usr/lib/x86_64-linux-gnu/hdf5/serial after Library_dirs: = $ (python_lib)/usr/local/lib/usr/lib
- Implement Caffe support for PYTHON and MATLAB interfaces python_lib: =/usr/local/lib
Here, the entire configuration file has been modified to start compiling,
- $ make All-j2
- $ make Test-j2
- $ make Runtest-j2
Compile the Caffe file used by Python
$ make pycaffe -j2
cuda8.0 compiler issue, open/usr/local/cuda/include/host_config.h comment out:
error -- unsupported GNU version! gcc versions later than 5.3 are not supported!
The results are as follows:
- #if __gnuc__ > 5 | | (__gnuc__ = = 5 && __gnuc_minor__ > 3)
- #error--Unsupported GNU version! GCC versions later than 5.3 is not supported!
- #endif/* __gnuc__ > 5 | | (__gnuc__ = = 5 && __gnuc_minor__ > 1) */
Caffe frame to this has been installed, enjoy watching the source bar! Part sixth Theano installation and configuration Direct input commands:
$ sudo pip install theano
Configuration parameters file:. THEANORC in Terminal input command:
Enter "I" into insert mode. Enter the content:
- [Global]
- Openmp=false
- Device=gpu
- Floatx=float32
- Allow_input-downcast=true
- [Blas]
- ldflags=
- [NVCC]
- Flags=-d_force_inlines
After entering, press ' ESC ' to exit, enter ': Wq ', return. Configuration Complete! To run the test example, create a new blank document to copy the following code to the suffix test.py:
- From Theano import function, config, shared, sandbox
- Import Theano.tensor as T
- Import NumPy
- Import time
- Vlen = ten * 768 # ten X #cores x # Threads per core
- Iters = 1000
- RNG = Numpy.random.RandomState (22)
- x = Shared (Numpy.asarray (Rng.rand (Vlen), CONFIG.FLOATX))
- f = function ([], T.exp (x))
- Print (F.maker.fgraph.toposort ())
- T0 = Time.time ()
- For I in Range (iters):
- R = f ()
- T1 = Time.time ()
- Print ("Looping%d times took%f seconds"% (Iters, t1-t0))
- Print ("Result is%s"% (r,))
- If Numpy.any ([Isinstance (X.op, t.elemwise) for x in F.maker.fgraph.toposort ()]):
- Print (' used the CPU ')
- Else
- Print (' used the GPU ')
Run at Terminal
$ python test.py
You can see the results as follows to complete the installation.
- /usr/bin/python2.7/home/hjimce/pycharmprojects/untitled/.idea/temp.py
- Using GPU Device 0:geforce 840M (Cnmem is disabled, CuDNN not available)
- [Gpuelemwise{exp,no_inplace} (<cudandarraytype (float32, vector) >), Hostfromgpu (Gpuelemwise{exp, no_inplace}.0)]
- Looping took 0.302778 seconds
- Result is [1.23178029 1.61879349 1.52278066 ..., 2.20771813 2.29967761
- 1.62323296]
- used the GPU
To this Theano environment to complete the seventh part of the Char-cnn+torch installation process installation Torch7 dependencies
- $ sudo apt-get Install curl
- $ Curl-sk Https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | Bash
Installing Torch distribution
- $ git clone https://github.com/torch/distro.git ~/torch--recursive
- $ cd ~/torch;./install.sh
Execute the following command to make the path changed during installation effective:
$ source ~/.bashrc
Execute the following command to see if torch installed successfully:
- $ th
- $ totch. tensor{1,2,3}
If you do not use torch, you can use the following command to uninstall: $ RM-RF ~/torch You can use the Luarocks command to install additional torch packages:
- $ luarocks Install image
- $ luarocks List
At this point torch the environment to complete the running CHAR-CNN, install the necessary packages:
- $ luarocks Install Nngraph
- $ luarocks Install Optim
Resources (thanks to the online bloggers for their shared learning and progress): 1. Install Python Scientific computing environment in Ubuntu HTTP://HYRY.DIP.JP/TECH/SLICE/SLICE.HTML/24/2, Ubuntu 15.10 Detailed procedures for configuring CAFFE+CUDA7.5+CUDNN HTTP://BLOG.SINA.COM.CN/S/BLOG_A5FDBF010102W7F6.HTML3, Deep Learning (41) cuda8.0+ Ubuntu16.04+theano, Caffe, TensorFlow Environment building http://blog.csdn.net/hjimce/article/details/519995664, ubuntu16.04+ Matlab2014a+anaconda2+opencv3.1+caffe installing Http://itfish.net/article/62996.html#5, Caffe & Theano Installation Tutorials-- ubuntu16.04 system http://blog.csdn.net/yahag/article/details/519680046, char-cnn+torch+ubuntu16.04 (RNN) installation process/HTTP blog.csdn.net/jeff_liu_sky_/article/details/51649084
Ubuntu16.04+cuda8.0rc+opencv3.1.0+caffe+theano+torch7 Construction Tutorial