"Caffe C + + interface use Description II" caffe_windows the use of C + + interface __c++

Source: Internet
Author: User
reproduced from: http://blog.csdn.net/happynear/article/details/45372231 Note:1 has succeeded in following this configuration and successfully tested the C + + interface for Windows Caffe 2) This first blog is the first step: reconfiguring a Caffe environment under Windows 0. Recent Updates

The content of this blog is all outdated and obsolete, need Caffe Windows version can install the official tutorial (https://github.com/BVLC/caffe/tree/windows) Install directly, also can follow my GitHub (https:/ /github.com/happynear/caffe-windows) in the instructions to install, the future updates will be on the GitHub, this blog will not be updated, please understand. First, prepare

Need to use the things I have to help everyone ready, there are February 4, 2016 just from Caffe official Master Branch fork over the source code: Https://www.github.com/happynear/caffe-windows. Have my own hand-made Third-party library http://pan.baidu.com/s/1bSzvKa, in the root directory of the source code to create a 3rdparty folder, the file can be unzipped.
After the decompression is done, add the 3rdparty/bin folder to the path of the environment variable so that the program can find the DLL for those third-party libraries.
Finally, the Cuda and Mkl, MKL is optional, you can go to the Intel official application, if not CPU mode does not matter, in the third party library I also provided the Openblas library files.
I am using the Cuda 7.5 version and recommend that you install this version as well.
   Second, compiling

The compilation is very simple and is divided into the following steps:
1. Double-click the./src/caffe/proto/extract_proto.bat batch file to generate Caffe.pb.h and caffe.pb.cc two C + + files, and caffe_pb2.py the file used by this python.
2, open./buildvs2013/mainbuilder.sln, switch the compile mode to release X64 mode after opening. If the load failed to display after opening, perhaps your cuda version and my inconsistency, my Cuda version 7.5, this time to use Notepad to open. vcxproj files in each folder under/buildvs2013 directory, search Cuda 7.5, replace this 7.5 with your own CUDA version, you can open it normally.
Also, if your video card is older or does not have a video card, use the./build_cpu_only/mainbuilder.sln.
3. Click the green triangle in the top toolbar to compile it. It may take about half an hour to compile, please wait patiently.

If you want to use the Matlab wrapper to extract features, observe the weight of training good, just want to Matcaffe project inside the MATLAB directory to modify into your own, and then compile, you can from matlab/+caffe/ Private folder inside find a file called Caffe_.mexw64.
Python's wrapper is similar to changing the Python directory in the Pycaffe project to your own (I'm using anaconda) to generate _caffe.pyd python DLL files in the Python/caffe folder. third, testing

To Http://pan.baidu.com/s/1mgl9ndu download the LEVELDB data file of the converted mnist, extract it into the./examples/mnist folder, and then run the Run_ under the root directory Mnist.bat can start training, the training log will be stored in the./log folder, starting with info, in TXT-formatted log file.

PS: If you compile successfully, don't forget to Point star to my GitHub project.
iv. Old update log

2015/02/25 Microsoft produced a caffe Windows version, they are more professional, made out of the solution easier to maintain, the Third-party library is completely managed by NuGet, almost no need to configure what things, suggest everyone to try: https:// Github.com/microsoft/caffe.
2015/12/09 I summed up some of the more common problems, written in the Https://github.com/happynear/caffe-windows/blob/master/FAQ.md, and the future will continue to update, If you encounter a problem, please check out this FAQ list first.
2015/09/14 Caffe now supports stand-alone multiple GPU, and can be trained using multiple GPU directly after Caffe command plus--gpu=all or--gpu=0,1.
If you use multiple GPU training, do not directly point to the CMD window x, it is best to use CTRL + C to terminate the program, otherwise the graphics driver will sometimes crash.
And if you want to save a snapshot in the middle of training, you can use Ctrl+break.
The operation of a normal termination training is therefore:
First Ctrl+break Save the current working state, then CTRL + C terminates the training.

The

2015/08/18 Lmdb can now be used, but the disk must be in NTFS format. If necessary, please go to http://pan.baidu.com/s/1ddhbbgp  to download and overwrite the file with the same name in 3rdparty/lib , then right-click the project-> only for projects-> link only, no need to regenerate. &NBSP
2015/08/08 A lot of people reported (including myself) that CUDNN V3 was much slower than V2, so the master branch was rolled back to the V2 version, and luckily Cudnn backwards-compatible, so there was no need to download the Third-party library again. &NBSP
2015/08/06 version of the new Caffe-windows online, because the vs2012 compilation speed is too slow, starting from this version, no longer provide support for vs2012. &NBSP
2015/07/07 Now Caffe also supports VS2013, and third party libraries are all updated to the latest version. Please download and replace the original build folder from the   Http://pan.baidu.com/s/1sj3IvzZ Http://pan.baidu.com/s/1i390tZB, and the other steps are consistent with previous versions. If you find a bug, please feedback to me, leave a message or mention issue on GitHub. &NBSP
Add Insanity Layer (that is, randomized leaky rectified linear units) in 2015/06/07, I don't know why it's called insanity. The paper says the effect is better than prelu. &NBSP
2015/06/05 to update the Caffe version to the master branch of June 5, the biggest difference with the previous version is that the Matlab interface is richer, CUDNN update to v2 version, so to download the Third-party library. &NBSP
2015/06/05 Batch Normalization is updated to the new edition, and the default Mnist test file is the version that uses the Batch normalization layer. &NBSP
2015/05/29 found that the previous version of the lmdb.lib used someone else to compile the vs2013 version, is now vs2012 version;
2015/05/29 added a MATLAB interface to extract any layer features, using the method:

OUTPUT = Caffe (' Get_features ', INPUT, ' layername1,layername2 ... ');
     
     
      
      1
     
     
     
     
      
      1
     
     

For example: F = Caffe (' Get_features ', H, ' conv51,pool5 '); The returned F is the cell type of 2*1, which records the name of the layer and the characteristics of that layer.
There is now a better way to get each layer of features, and the function is no longer updated. Please see the new version of MATLAB

Second Blog: http://blog.csdn.net/sinat_30071459/article/details/50974695

1 after reading the first blog, the description of your Windows under the Caffe environment has been configured to complete

2) Now modify the caffelib file according to the following blog

This article assumes that you have installed the Cuda,cuda version is 7.5.1. Compile Caffe version of WindowsHappynear's blog has introduced how to compile the caffe in Windows, where I have compiled the process of recording down, but also as a note-making, easy to view later.
1.1 Download Caffe-windows-masterDownload Address: Caffe-windows-master
1.2 Download the third party libraryDownload Address: 3rdparty
1.3 DecompressionUnzip the third party library 3rdparty and extract it into the 3rdparty folder in Caffe-windows-master, that is, the contents of the Caffe-windows-master/3rdparty are:
。。。 Then, you need to add the Bin folder to the environment variable.
Of course, if trouble, download my unpacked good files on the line, skip the above process, download the file, download the address: click here.
1.4 Start CompilingDouble-click Caffe-windows-master\src\caffe\proto\extract_proto.bat to generate Caffe.pb.h and caffe.pb.cc two C + + files, and Caffe_ pb2.py the file used by this python. Then, open the./buildvs2013/mainbuilder.sln with vs2013 and switch the compile mode to release X64 mode after opening. If your Cuda version is not 7.5, it may appear that the load failed after you open it./buildvs2013/msvc/mainbuilder.vcxproj, search Cuda  7.5, replace this 7.5 with your own CUDA version, you can open it normally. Right-click the Caffelib project, configure the properties--> general, modify the configuration type to application (. exe), modify the destination file extension to. exe, and then: C/c++--> General, the additional include directory is modified as follows (Cuda path is modified by itself):[Plain]View Plain Copy ... /.. /3rdparty/include.. /.. /src.. /.. /include C:\Program files\nvidia GPU Computing toolkit\cuda\v7.5\include linker--> General, the additional library directory is modified as follows (CUDA path is modified by itself):[Plain]View Plain Copy ... /.. /3rdparty/lib[Plain]View plain copy C:\Program Files\nvidia GPU Computing toolkit\cuda\v7.5\lib\x64
linker--> input; Cudnn64_65.lib modified to Cudnn.lib
If you need the MATLAB and Python interface, you can refer to the following settings (path by their own settings):

Matcaffe Project:

Additional Include directory:

[plain] view plain copy ... /.. /3rdparty/include.. /.. /src.. /.. /include C:\Program files\nvidia GPU Computing toolkit\cuda\v7.5\include D:\Program Include

Additional Library directory:

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.