Caffe + Ubuntu 14.04 64bit + CUDA 6.5 configuration Instructions 2

Source: Internet
Author: User
Tags intel mkl gtx

1. Installing Build-essentials

Install some basic packages needed for development

Install Build-essential
2. Install the Nvidia driver (3.4.0) 2.1 Preparation work (2014-12-03 Update)

In the case of shutting down the desktop management LIGHTDM, installing the driver seems to implement Intel HD graphics to display + NVIDIA graphics card to calculate. The steps are as follows:

1. First select the Intel graphics card to display or use as the primary display device in the BIOS setup.

2. Enter Ubuntu, press ctrl+alt+f1 to enter TTY, log in to TTY and enter the following command

sudo service LIGHTDM stop

The command closes LIGHTDM. If you are using GDM or another desktop manager, please close the NVIDIA driver before installing it.

2.2 Mounting the driver

Enter the following command to add the drive source

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

Installs version 340 driver (CUDA 6.5.14 currently only supports version 340 driver, 343, 346 version of the driver is not supported temporarily)

Install nvidia-340

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

Install nvidia-340-UVM

Reboot after installation is complete.

3. Installing Cuda 6.5

"Click this link" to download Cuda 6.5.

Then use the following command to extract the downloaded. Run file into three files, respectively

    • 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

Nvidia drivers are not installed here

Cuda6. 5.run--extract=extract_path

Note that you need to execute permissions for all. Run files by following command

chmod +x *.run

3.1 Installing Cuda

Install Cuda with the following command, and follow the instructions to install it step by step.

sudo./cuda-linux64-rel-6.5.  14-18749181.run  

3.1.1 Adding environment variables

After the installation is complete, add the environment variables to the/etc/profile and add the following files 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

3.1.2 Adding a Lib library path

In /etc/ld.so.conf.d/ , add the file cuda.conf as follows:

/usr/local/cuda-6.5/lib64

Execute the following command to make it effective immediately

sudo ldconfig

3.2 Installing Cuda SAMPLE

Install the following dependent packages first

Install Freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev Libglu1-mesa-dev

Then install the sample file with the following command

sudo./cuda-samples-linux-6.5.  14-18745345.run  

Compile the sample file after completion, the whole process about 10 minutes

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

After all compilation is complete, go to samples/bin/x86_64/linux/release, sudo run devicequery

sudo./devicequery

If the following graphics card information appears, the driver and the video card installation is successful:

./Devicequery starting ... CUDA Device Query (Runtime API) version (Cudart static linking) detected1CUDA capable device (s) device0:"GeForce GTX 670"CUDA Driver Version/runtime Version6.5/6.5CUDA Capability Major/minor Version number:3.0Total amount of global memory:4095 MBytes (4294246400bytes) (7) Multiprocessors, (192) CUDA CORES/MP:1344CUDA cores GPU Clock rate:1098 MHz (1.10GHZ) Memory Clock rate:3105Mhz Memory Bus Width:256-Bit L2 Cache Size:524288Bytes 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),2048Layers Maximum Layered 2D Texture Size, (num) layers 2d= (16384,16384),2048Layers total amount of constant memory:65536Bytes Total amount of shared memory per block:49152Bytes total number of registers available per block:65536Warp Size:32Maximum number of threads per multiprocessor:2048Maximum number of threads per block:1024Max 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:2147483647Bytes Texture Alignment:512Bytes Concurrent copy and kernel Execution:yes with1Copy engine (s) RunTime 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 locat Ion 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 you can not install Openblas instead) unzip the installation package, there is a install_gui.sh file below, execute the file, the graphical installation interface will appear, follow the instructions step by step.

Note: The library path needs to be added after the installation is complete

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

Add content to a file

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

Note Replace the path with your own installation path. When you're done editing

sudo ldconfig

5. Installing OPENCV

Try not to install it manually, and someone on GitHub has already written the full 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 the dependencies, downloads the installation package, compiles and installs the OPENCV. The whole process is about half an hour.

Note that there may be an error in the middle

opencv-2.4.  9/MODULES/GPU/SRC/NVIDIA/CORE/NCVPIXELOPERATIONS.HPP (In anexplicit specialization  

Workaround in this: http://code.opencv.org/issues/3814 download ncvpixeloperations.hpp replace the files within the opencv2.4.9, and build again.

6. Installing Additional Dependencies

Ubuntu14.04 User Execution

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 User Reference official Note: http://caffe.berkeleyvision.org/installation.html

7. The Python environment required to install the Caffe

First install Pip and Python-dev (the system has Python environment by default, but we need to make Python-dev)

Install Python-dev Python-pip

Then execute the following command to install the additional packages required to compile the Caffe Python wrapper

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

When executing the above command, an error will result in the inability to fully install all required packages. The Anaconda package can be installed according to the official recommendations. Download the. sh file on the Anaconda website, execute it, and finally add the bin directory to the environment variable.

(updated 2014-12-03 )

It is recommended that you install the Anaconda package, which is independent of the Python library that comes with the system and provides the scientific operations Python library that most Caffe needs. It is important to note that when running Caffe, you may be able to report some errors that could not be found libxxx.so, and locate libxxx.so command found to be installed in Anaconda, the first thought is that under/etc/ld.so.conf.d/will $your _anaconda_path/lib joins the Ld_library_path. However, this may result in the log out of the desktop can no longer enter!!! The reason (speculation) may be that some content in the lib of Anaconda conflicts with the Lib that comes with the system.

The correct approach is: In order to not let the system at the start of the anaconda/lib into the System library directory, you can add the library path in the user's own ~/.BASHRC, for example, I added two lines at the end

# Add library pathld_library_path=your_anaconda_path/lib: $LD _library_pathexport ld_library_path

After opening another terminal, it takes effect, and after reboot, the LIGHTDM can be loaded smoothly to enter the desktop environment.

8. Installing MATLAB

Caffe provides MATLAB interface, the need to use MATLAB students can install additional MATLAB. Please search by yourself for the installation tutorial.

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 should uncompress the. iso file. Then use sudo cp to copy the patch file)

9. Compiling Caffe

Finally completed the configuration of all the environment, you can happily compile Caffe! Go to the Caffe root directory and first copy the Makefile.config

CP Makefile.config.example Makefile.config

And then modify the content inside, the main parameters that need to be modified include

Cpu_only whether to use only CPU mode, no GPU does not have CUDA students can open this option

BLAS (using Intel MKL or Openblas)

Matlab_dir If you need to use MATLAB wrapper you need to specify the installation path of MATLAB, such as my path is/usr/local/matlab/r2013b (note that the directory needs to include the Bin folder, The Bin folder should contain the MEX binaries)

If debug is using debug mode, open this option to debug the program in Eclipse or Nsight

Once setup is complete, start compiling

Make all –J4make test makeruntest   

Note-j4 refers to the use of several threads at the same time to compile, can speed up, j after the number can be based on the number of CPU cores to determine, my CPU makes 4 cores, so-j4.

Then go pee, drink a cup of tea, come back almost compiled.

9.1. Compiling MATLAB wrapper

Execute the following command

Make Matcaffe

Then you can run the official MATLAB demo.

9.2. Compiling Python Wrapper

And then basically install all the pull-out.

Next, let's Run the demo.

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

10. Installing CUDNN

To speed up the caffe, you can install CuDNN, see this article: NVIDIA CuDNN Installation Instructions

Caffe + Ubuntu 14.04 64bit + CUDA 6.5 configuration Instructions 2

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.