Caffe + Ubuntu 14.04 64bit + CUDA6.5 + no GPU configuration

Source: Internet
Author: User
Tags windows download wrapper

Website:

Http://caffe.berkeleyvision.org/installation.html#compilation

Reference website:

Http://www.cnblogs.com/dupuleng/articles/4213834.html

Http://www.cnblogs.com/empty16/p/4793404.html

--------------------------------------------------------------------------------------------------------------- ----------------------

First, install the Build-essentials

Install some basic packages needed for development

1 sudo apt-get Install build-essential

Second, CUDA installation

This step consists of three parts:

    1. NVIDIA driver
    2. Cuda-toolkit
    3. Cuda-samples

You only need to install Cuda-toolkit in CPU mode, and then we'll show you how to install Cuda-toolkit

2.1 Downloads CUDA6.5

Download mode: Windows Download (http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.14_linux_64.run) Upload to Ubuntu via SSH

or enter it directly in Ubuntu:

1 wget http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.14_ Linux_64.run

Increase the Execute permission for the. run file by using the following command:

1 chmod +x *.run

Then unzip the downloaded file:

./cuda_6. 5. 14_linux_64.run  --extract=extract_path  (note: the need to change the Extract_path to the location where the files were extracted)

Unzip the downloaded. Run file, get three files, we only install the first one, i.e. the Cuda-toolkit package

      • CUDA installation package: Cuda-linux64-rel-6.5.14-18749181.run
      • NVIDIA Driver: Nvidia-linux-x86_64-340.29.run
      • Sample package: Cuda-samples-linux-6.5.14-18745345.run

2.2 Installing Cuda

Cuda needs to be performed on a pure command line (very important), press CTRL+ALT+F1 to enter the TTY, log in and execute the following command

sudo service lightdm stop  or sudo stop LIGHTDM

Execute the following command to install CUDA, follow the prompts step by step installation, which will let you choose the installation directory, accept the protocol, etc., in order to facilitate the selection of the default path, directly enter.

sudo./cuda-linux64-rel-6.5.14-18749181.run

2.3 Adding environment variables

After the installation is complete, add the environment variable in the/etc/profile and add the file at the end

Path=/usr/local/cuda-6.5/bin: $PATHexport PATH

Once saved, execute the following command to make the environment variable effective immediately

Source/etc/profile

2.4 Adding a Lib library path

Add the file cuda.conf in the/etc/ld.so.conf.d/directory as follows

/usr/local/cuda-6.5/lib64

Execute the following command to take effect immediately

sudo ldconfig

    Note: If you do not use the default path, replace the path above with your own path

2.5 Exit command Line

sudo service lightdm start or sudo start LIGHTDM

Third, installation Blas

There are three versions of Blas: ATLAS, MKL, Openblas. MKL is charged, also use student version, but need to use your organization's mailbox to apply, the other two kinds are free, here use Openblas. I heard that the MKL is much more efficient than the other two types.

1.:

1 wget https://codeload.github.com/xianyi/openblas/tar.gz/v0.2.15

2. Unzip

1 tar-zvxf openblas-0.2.  the

3. Enter the extracted files for compilation and installation:

Direct input: Make; Estimated error: make[1]: * * * [SGEMM.O] Error 1

Then input: Make Target=nehalem

After compiling, it will prompt similar to: make Prefix=/your/path/lib install, etc., it means to install LIB to the corresponding address

Input: Make prefix=/usr/local/openblas/

4. Add the Lib Library path: in the/etc/ld.so.conf.d/directory, add the file openblas.conf, the content is as follows

/usr/local/openblas/lib

5. Execution of the following commands takes effect immediately

sudo ldconfig

Iv. installation of OpenCV

    1. Download the installation script from GitHub: Https://github.com/jayrambhia/Install-OpenCV
    2. Make ubuntu/2.4 directory, add executable permissions to all scripts
sudo chmod +x *.sh

Install the latest version (currently 2.4.9), someone wrote 2.4.20 version, interested can go down: http://pan.baidu.com/s/1m3hQu

3. Install dependencies

sudo./dependencies.sh

4. Install OpenCV 2.4.9

sudo sh./opencv2_4_9.sh

This piece of time longer, to ensure network connectivity, need to download the installation package online.

Note: There may be errors in the middle:

1 opencv-2.4.9/modules/gpu/src/nvidia/core/NCVPixelOperations.hpp(51): error: a storage classis not allowed in an explicitspecialization

Solution: Download NCVPIXELOPERATIONS.HPP, replace ubuntu/2.4/opencv/opencv2.4.9/moduels/gpu/src/nvidia/ NCPIXELOPERATIONS.HPP file in the core directory, re-execute the installation command

sudo sh./opencv2_4_9.sh

V. Installing other dependencies

Ubuntu14.04 User Execution

sudo apt-get install Libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev Libhdf5-serial-dev Libgflags-dev Libgoogle-glog-dev Liblmdb-dev Protobuf-compiler

Other version Reference official website description

Vi. the Python environment required to install the Caffe (not tested)

Choose a suitable IDE running environment, the author uses the Spyder, because it built-in IPython environment, Caffe a lot of programs are based on IPython environment. The installation method is simple and can be installed by searching the "Spyder" directly in Ubuntu Software Center.

Vii. the MATLAB environment required to install the Caffe

    1. Download: From the Internet to find resources, Baidu Cloud disk has more resources. Note: Caffe only supports versions above matlab12b
    2. Installation specific process reference: http://blog.csdn.net/aimatfuture/article/details/8058156

Eight, compile Caffe

    • Download: Https://github.com/BVLC/caffe
    • Go to the Caffe directory and copy an Makefile.config
CP Makefile.config.example Makefile.config
    • Modify the content according to your environment

1 Cancel Cpu_only: = 1 comments in front of

2. Cuda installation path changed to its own path: cuda_dir: =/usr/local/cuda-6.5

3. Configure the path: Implement Caffe support for Python and MATLAB interfaces

Python_include: =/usr/include/python2.7/usr/lib/python2.7/dist-packages/numpy/core/includepython_lib: =/usr/ Local/libinclude_dirs: = $ (python_include)/usr/local/includelibrary_dirs: = $ (python_lib)/usr/local/lib/usr/ Libmatlab_dir: =/usr/local/matlab/r2014a

4. BLAS: = open (based on the version of your choice, set to Atlas, MKL, open

Blas_include: =/usr/local/openblas/include

blas_lib: =/usr/local/openblas/lib

Makefile: BLAS? = Atlas changed to: BLAS? = Open

    • Compiling Caffe
sudo make all-j2sudo make test sudo make runtest

    

In this step you may encounter a problem: undefined refrence to ' cudagetdevice '

Workaround:

1. Modify Makefile.config, modify custom_cxx: = g++-4.6

2. Execute command sudo apt-get install gcc-4.6 g++-4.6 gcc-4.6-multilib g++-4.6-multilib
3. Modify the following two files
VI src/caffe/common.cpp
VI tools/caffe.cpp
Using Google alternative gflags

4. Re-make

If you are prompted in the make process: "Error while loading shared libraries:xxx.so.x", it is possible that cuda and Openblas environment variables are not set correctly, check the appropriate steps, refer to:/http blog.csdn.net/sahusoft/article/details/7388617

Nine, compiling Matlab wrapper

Make Matcaffe

Ten, compiling Python wrapper

Make Pycaffe

Xi. testing with the Mnist data set

This section can refer to Caffe official website: http://caffe.berkeleyvision.org/gathered/examples/mnist.html, very detailed.

  Note: This section is done by default in the Caffe directory, and cannot be executed in the corresponding subdirectory because the path in the script is relative to the Caffe target.

    1. Get data: sudo sh data/mnist/get_mnist.sh
    2. Rebuild Lmdb/leveldb file: sh examples/mnist/create_mnist.sh ( Caffe supports three data format inputs: images (. Jpg,.png, etc.), Leveldb, Lmdb)
    3. Switch to CPU mode: Modify Solover_mode = CPU in Lenet_solver.prototxt, in the last line
    4. Training Minist:sudo SH examples/mnist/train_lenet.sh

Without errors, you can see a string of output information.

12, in CPU mode, so do not install CUDNN

Caffe + Ubuntu 14.04 64bit + CUDA6.5 + no GPU configuration

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.