Ubuntu14.04 Configuration Cuda-convnet

Source: Internet
Author: User
Tags cuda toolkit

Reprint Please specify: http://blog.csdn.net/stdcoutzyx/article/details/39722999

In the previous link, I configured cuda, there is a powerful GPU, nature can not throwaway, let resources in vain, so configure the convolutional neural network run the program. As for the principle of convolutional neural networks, write again. intends to write the use of the library, and then write the principle of action to promote the pursuit of the theory.

Words do not say much, step into the chase.

1. Pre-description

About cuda-convnet, originated from a classic paper ①, the paper for ILSVRC-2010 data to experiment, and then published its experiment using the code, link to ②. However, the fact is often a gap with the paper, the code in the link ② can not reproduce the results in the paper at all. In the next, in the use of this link to the library long after the discovery, feel very pit, I hope that later people cautious.

The reason that it pits, first of all, in the paper mentioned features,Multi-gpu and dropout did not achieve, and did not give the paper 8 The configuration file for the layer convolutional neural network. In short, can not directly use, you need to explore.

Even so, there is always better than nothing, after all, the convolutional neural network implemented by this library is encapsulated well, and the contribution of the great God in this paper is not something I can achieve with my side dishes. Give the great god a good three-point.

This article only describes the configuration of cuda-convnet and cuda-convnet2 , the author of the paper also published other versions of the library, has not been used, so and do not mention.

2. Cuda-convnet configuration 2.1. Source code Download

Refer to the link ②, first download the source code down.

SVN checkout Http://cuda-convnet.googlecode.com/svn/trunk/cuda-convnet-read-only

The version removed is 562.

2.2. Install the necessary libraries

Then, to install the necessary libraries, I am using the ubuntu System. So the command is

sudo apt-get install Python-dev python-numpy python-magic python-matplotlib Libatlas-base-dev

Of course, also confirm that you have cudainstalled, I installed the cuda6.5, in the /usr/local/ directory, as follows:

$ ls/usr/localbin  cuda  cuda-6.5  etc  Games  include  Lib  man  sbin  Share  SRC

2.3. Change build.sh

Go to the cuda-convnet-read-only directory you just downloaded , and change The configuration path in the build.sh file. As shown below:

# CUDA Toolkit Installation directory.export Cuda_install_path=/usr/local/cuda # cuda SDK installation Directory.export C Uda_sdk_path=/usr/local/cuda-6.5/samples/common/inc # Python include directory. This should contain the file Python.h, among Others.export python_include_path=/usr/include/python2.7 # Numpy INCLUDE Dire Ctory. This should contain the file arrayobject.h, among Others.export numpy_include_path=/usr/lib/python2.7/dist-packages/ Numpy/core/include/numpy # ATLAS Library directory. This should contain the file libcblas.so, among Others.export atlas_lib_path=/usr/lib/atlas-base make $*


According to the official website of the tutorial, after configuring the build.sh can be compiled. But there will be errors, and there are several places to change.

2.4. header file Additions

Direct compilation will cause an error that cannot be found for the cutil_inline.h header file. The reason for the analysis may be that the original header file, and later the function of the header file is implemented into other header files.

In the include sub-folder, field cutil_inline.h file and enter content.

#include "helper_cuda.h" #define CUTILCHECKMSG (a) getlastcudaerror (a) #define CUTGETMAXGFLOPSDEVICEID () Gpugetmaxgflopsdeviceid () #define MIN (a) < (b) (a): (b)

2.5. MakeFile file Changes

MakeFile Line 3 , the original text reads as follows:

Includes: =  -i$ (python_include_path)-i$ (Numpy_include_path)-i./include-i./include/common-i./include/ Cudaconv2-i./include/nvmatrix

After adding the cuda Path, follow these steps:

Includes: =  -i$ (python_include_path)-i$ (Numpy_include_path)-i$ (Cuda_sdk_path)-i./include-i./include/common -i./include/cudaconv2-i./include/nvmatrix

Save it.

2.6. Last Library link error

After the above changes can be compiled, but in the end there will be a library link error, no tube, directly to the library comment out.

The 332 line in the common-gcc-cuda-4.0.mk file . Comment directly with the # sign.

# LIB + =-lcutil_$ (lib_arch) $ (libsuffix)-lshrutil_$ (lib_arch) $ (libsuffix)

At this point, you can complete the compilation of Cuda-convnet.

3. Cuda-convnet2 configuration

As the name implies, this is the 2.0 version of cuda-convnet , which supports multi- GPU operation.

3.1. Source code Download

git clone https://code.google.com/p/cuda-convnet2/

3.2. The necessary library

sudo apt-get install Python-dev python-numpy python-scipy python-magic python-matplotlib libatlas-base-dev Libjpeg-dev Libopencv-dev

3.3. Configuration

I can only say that this version is more humanized than the previous version, this version of the build.sh directly.

# CUDA Toolkit Installation directory.export Cuda_install_path=/usr/local/cuda # Python include directory. This should contain the file Python.h, among Others.export python_include_path=/usr/include/python2.7 # Numpy INCLUDE Dire Ctory. This should contain the file arrayobject.h, among Others.export numpy_include_path=/usr/lib/python2.7/dist-packages/ numpy/core/include/numpy/# ATLAS Library directory. This should contain the file libcblas.so, among Others.export atlas_lib_path=/usr/lib/atlas-base # you don ' t has to Chang E these:export ld_library_path= $CUDA _install_path/lib64: $LD _library_pathexport cuda_sdk_path= $CUDA _install_path/ Samplesexport path= $PATH: $CUDA _install_path/bin

If it is under Ubuntu , then it is basically the right way to configure the path.

3.4. Link Errors

However, if you compile directly, you will still encounter errors, as follows:

CD./bin/&& g++  -o3   -dnumpy_interface-shared-wl,-no-undefined-o libutilpy.so src/matrix.o-l/usr/ Lib/atlas-base-latlas-lcblas-lpython2.7/usr/bin/ld:cannot Find-latlas/usr/bin/ld:cannot Find-lcblascollect2: Error:ld returned 1 exit status

The main reason is that there are no libatlas.so and libctlas.so in the Atlas Library. View the directory for Atlas Discovery structure:

:/usr/lib/atlas-base$ ls-l Total dosage 4292drwxr-xr-x 2 root root    4096  September 11:41 atlaslrwxrwxrwx 1 root root  February  4  libatlas.so.3-libatlas.so.3.0-rw-r--r--1 root root 3746968  February  4  2014 libatlas.so.3.0lrwxrwxrwx 1 root root  February  4 libcblas.so.3-  libcblas.so.3.0-rw-r--r--1 Root root  135376  February  4  libcblas.so.3.0lrwxrwxrwx 1 root root  4 February  Libf77blas.so.3-libf77blas.so.3.0-rw-r--r--1 root root  131000  February  4  2014 libf77blas.so.3.0lrwxrwxrwx 1 root root  February  4 liblapack_atlas.so.3-  Liblapack_ atlas.so.3.0-rw-r--r--1 root root  369472  February  4  liblapack_atlas.so.3.0

Add two soft links to execute the command:

sudo ln-s libatlas.so.3.0 libatlas.sosudo ln-s libcblas.so.3.0 libcblas.so

The directory structure changes to this:

/usr/lib/atlas-base$ ls-l Total dosage 4292drwxr-xr-x 2 root root    4096  September 11:41 atlaslrwxrwxrwx 1 root root      15 October 
   1 22:35 libatlas.so, libatlas.so.3.0lrwxrwxrwx 1 root root      ,  February  4  libatlas.so.3 libatlas.so.3.0-rw-r--r--1 root root 3746968  February  4  libatlas.so.3.0lrwxrwxrwx 1 root root      15 October  1 22:36 libcblas.so-libcblas.so.3.0lrwxrwxrwx 1 root root  February  4  libcblas.so.3-& Gt libcblas.so.3.0-rw-r--r--1 root root  135376  February  4  libcblas.so.3.0lrwxrwxrwx 1 root root  February  4 libf77blas.so.3-  libf77blas.so.3.0-rw-r--r--1 root root  131000  February  4  libf77blas.so.3.0lrwxrwxrwx 1 root root  February  4  liblapack_atlas.so.3- > liblapack_atlas.so.3.0-rw-r--r--1 root root  369472  February  4  liblapack_atlas.so.3.0

Then you can compile it properly.

Reference Documents

①imagenet classification with deep convolutional neural Networks

② https://code.google.com/p/cuda-convnet

③ Https://code.google.com/p/cuda-convnet2

Ubuntu14.04 Configuration Cuda-convnet

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.