Caffe + Ubuntu14.0464bit + CUDA6.5 configuration instructions

Source: Internet
Author: User
Tags intel mkl gtx
(Caffe + Ubuntu14.0464bit + CUDA6.5 configuration instructions. This document uses the same NVIDIA graphics card for display and computation. If different graphics cards are used for display and computation, they may not apply .) 1. Install build-essential tials install some of the basic packages required for development sudoapt-getinstallbuild-essential2. Install the NVIDIA Driver (3.4.0)

(Caffe + Ubuntu 14.04 64bit + CUDA 6.5 configuration instructions. This document uses the same NVIDIA graphics card for display and computing. If different graphics cards are used for display and computing, they may not apply .)

1. Install build-essential

Install some basic packages required for development

sudo apt-get install build-essential
2. Install the NVIDIA Driver (3.4.0) 2.1 preparation)

When the Desktop Management lightdm is disabled, it seems that the driver can be installed with an Intel Core graphics card for display + NVIDIA graphics card for computation. The procedure is as follows:

1. First, select Intel graphics card for display in BIOS settings or as the main display device

2. Go to Ubuntu and press ctrl + alt + F1 to enter tty. After logging on to tty, enter the following command:

sudo service lightdm stop

This command will disable lightdm. If you are using a running the running of the NVIDIA driver, disable it before installing the NVIDIA driver.

2.2 install driver

Enter the following command to add the driver source

sudo add-apt-repository ppa:xorg-edgers/ppasudo apt-get update

Install the 340 Driver (CUDA 6.5.14 currently supports up to 340 drivers, not 343,346 drivers)

sudo apt-get install nvidia-340

After the installation is complete, continue to install the following packages (otherwise, an error will be reported when running the sample)

sudo apt-get install nvidia-340-uvm

Reboot after installation.

3. Install CUDA 6.5

Click here to download CUDA 6.5.

Run the following command to decompress the downloaded. run file into three files:

  • CUDA package: cuda-linux64-rel-6.5.14-18749181.run
  • Nvidia driver: NVIDIA-Linux-x86_64-340.29.run
  • SAMPLE: cuda-samples-linux-6.5.14-18745345.run

NVIDIA driver is not installed here

cuda6.5.run --extract=extract_path

Note: run the following command to grant executable permissions to all. run files:

chmod +x *.run 
3.1 install CUDA

Run the following command to install CUDA.

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

3.1.1 Add Environment Variables

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

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

After saving, execute the following command to make the environment variable take effect immediately

source /etc/profile

3.1.2 Add the lib LIBRARY PATH

In/Etc/ld. so. conf. d/Add FileCuda. conf,The content is as follows:

/usr/local/cuda-6.5/lib64

Execute the following command to make it take effect immediately

sudo ldconfig 
3.2 install CUDA SAMPLE

First install the following dependency packages

sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa-dev

Run the following command to install the sample file:

sudo ./cuda-samples-linux-6.5.14-18745345.run

Compile the Sample file after completion. The entire process takes about 10 minutes.

cd /usr/local/cuda-6.5/samplessudo make

After compilation is complete, go to samples/bin/x86_64/linux/release and run deviceQuery in sudo.

sudo ./deviceQuery

If the following video card information appears, the driver and video card are successfully installed:

./deviceQuery Starting... CUDA Device Query (Runtime API) version (CUDART static linking)Detected 1 CUDA Capable device(s)Device 0: "GeForce GTX 670"  CUDA Driver Version / Runtime Version          6.5 / 6.5  CUDA Capability Major/Minor version number:    3.0  Total amount of global memory:                 4095 MBytes (4294246400 bytes)  ( 7) Multiprocessors, (192) CUDA Cores/MP:     1344 CUDA Cores  GPU Clock rate:                                1098 MHz (1.10 GHz)  Memory Clock rate:                             3105 Mhz  Memory Bus Width:                              256-bit  L2 Cache Size:                                 524288 bytes  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers  Total amount of constant memory:               65536 bytes  Total amount of shared memory per block:       49152 bytes  Total number of registers available per block: 65536  Warp size:                                     32  Maximum number of threads per multiprocessor:  2048  Maximum number of threads per block:           1024  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)  Maximum memory pitch:                          2147483647 bytes  Texture alignment:                             512 bytes  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)  Run time limit on kernels:                     Yes  Integrated GPU sharing Host Memory:            No  Support host page-locked memory mapping:       Yes  Alignment requirement for Surfaces:            Yes  Device has ECC support:                        Disabled  Device supports Unified Addressing (UVA):      Yes  Device PCI Bus ID / PCI location ID:           1 / 0  Compute Mode:     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 6.5, CUDA Runtime Version = 6.5, NumDevs = 1, Device0 = GeForce GTX 670Result = PASS
4. Install Intel MKL

(If OpenBLAS cannot be installed, decompress the installation package. The following is an install_GUI.sh file. to execute this file, a graphical installation interface is displayed. Follow the instructions to perform the installation step by step.

Note: After installation, you need to add the library path.

sudo gedit /etc/ld.so.conf.d/intel_mkl.conf

Add content to the file

/opt/intel/lib/opt/intel/mkl/lib/intel64

Replace the path with your own installation path. After editing, run

sudo ldconfig 
5. Install OpenCV

This try not to install manually, someone on Github has written the complete installation script: https://github.com/jayrambhia/Install-OpenCV

Download the script, go to the Ubuntu/2.4 directory, and add executable permissions to all shell scripts.

chmod +x *.sh

Then install the latest version (currently 2.4.9)

sudo ./opencv2_4_9.sh

The script automatically installs dependencies, downloads the installation package, compiles and installs OpenCV. The entire process is about half an hour.

Note: An error may be reported during the process.

opencv-2.4.9/modules/gpu/src/nvidia/core/NCVPixelOperations.hpp(51): error: a storage class is not allowed in an explicit specialization

Solution here: the http://code.opencv.org/issues/3814 downloads NCVPixelOperations. hpp to replace the files in opencv2.4.9 and then build again.

6. install 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 versions of user reference official instructions: http://caffe.berkeleyvision.org/installation.html

7. Install the Python environment required by Caffe

First install pip and python-dev (the system has a python environment by default, but we need to make python-dev)

sudo apt-get install python-dev python-pip

Run the following command to install and compile the additional package required by caffe python wrapper:

for req in $(cat requirements.txt); do sudo pip install $req; done

When executing the preceding command, an error is reported, resulting in the failure to install all required packages. You can install the anaconda package as recommended. Download the. sh file from the official anaconda website, execute the file, and add the bin directory to the environment variable.

(Update)

We recommend that you install the Anaconda package, which is independent of the python library that comes with the system and provides the scientific computing Python library required by most Caffe. Note that when running Caffe, libxxx may not be found. so error, and use locate libxxx. the so command has been installed in anaconda. The first thing that comes to mind is in/etc/ld. so. conf. d/Add $ your_anaconda_path/lib to LD_LIBRARY_PATH. However, this may cause logout and the desktop cannot be accessed again !!! The cause (speculation) may be that some content in anaconda lib conflicts with the built-in lib.

The correct method is: to prevent the system from adding anaconda/lib to the system library directory at startup, you can ~ /. Add the library path in bashrc. For example, I added two rows at the end.

 

# add library pathLD_LIBRARY_PATH=your_anaconda_path/lib:$LD_LIBRARY_PATHexport LD_LIBRARY_PATH

It takes effect immediately after another terminal is enabled, and lightdm can be loaded smoothly after restart to enter the desktop environment.

8. Install MATLAB

Caffe provides the MATLAB interface. If you need MATLAB, you can install MATLAB. Please search for installation tutorials by yourself.

Add icon http://www.linuxidc.com/Linux/2011-01/31632.htm after installation is complete

sudo vi /usr/share/applications/Matlab.desktop

Enter the following content

[Desktop Entry]Type=ApplicationName=MatlabGenericName=Matlab 2010bComment=Matlab:The Language of Technical ComputingExec=sh /usr/local/MATLAB/R2010b/bin/matlab -desktopIcon=/usr/local/MATLAB/Matlab.pngTerminal=falseCategories=Development;Matlab;

 

(I use the R2013b patched package. First you shoshould uncompress the. iso file. Then useSudo cpTo copy the patch file)

9. Compile Caffe

Finally, all environment configurations have been completed and Caffe can be compiled happily! Go to the caffe root directory and copy Makefile. config.

cp Makefile.config.example Makefile.config

Then modify the content. The main parameters to be modified include

CPU_ONLY indicates whether only the CPU mode is used. You can enable this option if you do not have a GPU or CUDA installation.

BLAS (using intel mkl or OpenBLAS)

If you want to use MATLAB wrapper, You need to specify the installation path of matlab, for example,/usr/local/MATLAB/R2013b (note that the directory must contain the bin folder, the bin folder should contain the mex binary program)

Whether the DEBUG mode is used. If this option is enabled, You can debug the program in eclipse or NSight.

After completing the settings, start compiling.

make all -j4make testmake runtest

Note-j4 refers to the use of several threads to compile at the same time, which can accelerate the speed. The number after j can be determined based on the number of CPU cores. My CPU enables 4 cores, So-j4.

Then let's peat the urine and have a cup of tea. It's almost compiled ..

9.1. Compile Matlab wrapper

Run the following command:

make matcaffe

Then you can run the official matlab demo.

9.2. Compile Python wrapper
 make pycaffe 

Then, the installation is complete.

Next, let's take a look at the demo ~

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

10. Install cuDNN

To accelerate Caffe, you can install cuDNN. Refer to this article: NVIDIA CuDNN installation instructions.

Ubuntu 14.04 install and configure CUDA http://www.linuxidc.com/Linux/2014-10/107501.htm

Ubuntu 12.04 configuration NVIDIA CUDA5.5 real-time http://www.linuxidc.com/Linux/2014-10/107502.htm

Ubuntu installation Theano + CUDA http://www.linuxidc.com/Linux/2014-10/107503.htm

For Ubuntu 12.04 CUDA5.5 installation, see the following link Ubuntu 12.04 installation CUDA-5.5

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2015-04/116444.htm

Related Article

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.