Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup

The purpose of this series it to get caffe working in windows in the most quick and dirty way: I’ll provide 1) the modified file that can be compiled in windows right away; 2) the vs2013 project that I’m currently using. In short:

  1. Install CUDA, Boost, OpenCV.
  2. Download caffe code with vs2013 from GitHub.
  3. Download 3ryparty.zip and unzip to ‘3rdparty’ folder.
  4. Edit ‘Caffe-vs2013 – Debug.props’ and ‘Caffe-vs2013 – Release.props’ files so that the path of CUDA, Boost and OpenCV make sense for you. Also, the given ‘compute_50,sm_50’ is for Maxwell GPU. Change 50 to 20 for Fermi and 30 for Kepler.
  5. Open caffe-vs2013.sln.
  6. Set platform to Release, x64 and change ‘caffe’ project’s ‘Configuration Type’ to ‘Application (.exe)’.
  7. Right click on ‘caffe’ project and ‘compile’.
  8. Run test on MNIST.

  • For caffe.exe, please use Release|x64 mode. Debug version of caffe.exe makes no sense and is slow.
  • 32 bit version should work but lacking support for lmdb and hdf5 because I didn’t compile them. lol

Setup:

  1. CUDA 6.5
    • You have to have a Nvidia GPU on your PC to enable GPU version of Caffe. My impression was that you get maybe 10x speed-up using GPU over CPU, and another 10x speed-up by enable CuDNN library.
    • The installation will create system variable for you, e.g. CUDA_PATH_V6_5.
    • If you are using a GPU with the architecture of Fermi or Kepler: CUDA 6.5
    • If you are using a GeForce GTX9xx GPU with the architecture of Maxwell: CUDA 6.5 for Maxwell
    • Newer version of CUDA should be fine also.
  2. Boost
    • Pre-built version of boost are available. I’m using boost 1.56.0 myself. Get pre-built boost and install.
    • Add boost’s path to system’s path. I added BOOST_1_56_0:
      • System variable for boost
  3. OpenCV
    • Since we are not using GPU supported OpenCV here, e.g. GpuMat, etc. Pre-built version of OpenCV are good enough for a quick start.
    • I use OpenCV 3.0 here as example. Add system path variable for OpenCV also:
      • System variable for OpenCV
  4. System variable need ‘log off’ or ‘restart’ your system to take effect
  5. Download the code for caffe from my GitHub
    • The original code was forded from 7e465f2. Then I manually added the changes from #1416 to support “vector<Mat>”.
  6. Download the 3rdparty.zip and unzip its content to 3rdpary folder

Before compile (skip if you’re familiar with vs2013 already):

  • When it comes to a big project, many errors can happen. Let’s get things a bit clear first.
  • In a project, usually functions are declared in .h/.hpp files and implemented in .c/.cpp files. Missing .hpp file is usually shown in the editor and missing .cpp file usually gives linking error.
  • All .cpp files added to the vs project will be compiled to .obj files which can be linked later. While no .hpp files will be compiled. Adding .hpp files to the vs project or not makes no difference to the compiling.
  • If you want to include .hpp file from another project, e.g. OpenCV. You need to add the path of the header files to ‘AdditionalIncludeDirectories’.
    • Adding header files to the vs project does NOT add the path automatically.
    • Adding the path of .cpp files to ‘AdditionalIncludeDirectories’ is NOT needed and has NO effect.
    • For example if the file path is “D:\toolkits\opencv-3.0.0\build\include\opencv2\opencv.hpp”, you can either:
      • 1) add “D:\toolkits\opencv-3.0.0\build\include” to ‘AdditionalIncludeDirectories’ and write #include “opencv2/opencv.hpp”; or
      • 2) add “D:\toolkits\opencv-3.0.0\build\include\opencv2” to ‘AdditionalIncludeDirectories’ and write #include “opencv.hpp”;
  • After the .hpp file is included, the compiler knows that these functions exist so ‘unknown namespace cv’ kind of error will not happen any more.
  • After all .cpp files in your project are compiled, here comes the linking. The implementation of functions have to be either in .cpp files of your project or .lib files generated by other projects.
    • Enabling lib files requires 1) path to be added to ‘AdditionalLibraryDirectories’; and 2) file names to be added to ‘AdditionalDependencies’.
    • For example, you might add “D:\toolkits\opencv-3.0.0\build\x86\vc12\lib” to ‘AdditionalLibraryDirectories’ and add “opencv_ts300.lib; opencv_world300.lib;” to ‘AdditionalDependencies’.
    • Usually the path of lib files changes according to the ‘PlatformTarget’, i.e. ‘x86’, and the ‘Configuration’, i.e. ‘Debug’. I usually let Visual Studio handle the difference, e.g. I add “$(OPENCV_3_0_0)\$(PlatformTarget)\vc12\lib” for OpenCV in later sections.
  • If you solve compile error by having proper .hpp files and solve linking error by have proper .lib files, you program will run. Yet it might have missing .dll error.
    • Some library are compiled in the static way to generate .lib files only, like gflags, protobuf, etc.
    • Some library are compiled in the dynamic way to generate both .lib and .dll files. In this case your program will require .dll files on run-time.
    • Personally I like to copy required .dll files to the same folder of the .exe file for simplicity.

Compile:

  1. Open the ‘caffe-vs2013.sln’
    • In Property Manager you’ll see that 2 .props files are added to the project: ‘Caffe-vs2013 – Debug.props’ and ‘Caffe-vs2013 – Release.props’.
      • Property Manager
      • This is a very handy way to setup you project quickly. The idea is that some fixed configuration are written in the property sheet file, i.g. ‘Caffe-vs2013 – Release.props’. After that the project’s property, i.e. ‘Release|x64’, can inherit from it.
    • Open the ‘Caffe-vs2013 – Release.props’ from disk, you’ll see the setting for CUDA, Boost, OpenCV, etc. If your system path for CUDA, Boost, OpenCV are different from mine, you need to change them in these 2 .props files.
    • Output folder is changed to ‘$(SolutionDir)build\$(Platform)\$(Configuration)\’ for later use caffe as a lib in other projects.
    • Noted that ‘compute_50,sm_50′ in the 2 .props files means the generation of CUDA to use. ’50’ works for Maxwell GPU. Use ’20’ for Fermi and ’30’ for Kepler.
    • If you changed things in the .props files, you need to close and reopen your vs solution to take effect.
  2. Right click on ‘caffe’ and click ‘Property’. In ‘General’ -> ‘Configuration Type’, make sure it’s ‘Application (.exe)’.
  3. Make sure it’s Release and x64. Right click on ‘caffe’ and click ‘compile’. ‘caffe.exe’ will be generated to ‘build/x64/Release’ folder.
  4. Copy ‘opencv_ffmpeg300_64.dll’, ‘opencv_world300.dll’ from OpenCV to the folder of ‘caffe.exe’
  5. Copy the following from 3rdparty folder (be aware of the configuration, i.e. Debug/Release, Win32/x86) to the same folder of ‘caffe.exe’:
    • libglog.dll
    • libopenblas.dll
    • cudnn64_65.dll
    • msvcp120.dll
    • msvcr120.dll
  6. Run ‘caffe.exe’, should display like this:
    • cmd-caffe

Test on MNIST

  1. Go to ‘caffe/data/mnist’ folder and run ‘get_mnist.bat’ to fetch dataset for MNIST.
  2. Go to ‘caffe/examples/mnist’ folder and
    • run ‘create_mnist-leveldb.bat’ to convert MNIST dataset to leveldb format.
    • run ‘train_lenet-leveldb.bat’ to start the training.
  3. There’s a ‘lmdb’ version but it does NOT work. Fix was given by Kazukuni Hosoi here but I didn’t try it myself. Not a fan of lmdb.

Following

  • (II) Use caffe as lib like OpenCV in a normal vs2013 project.
Advertisements

97 thoughts on “Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup

  1. Hi,I’m fresh in caffe.when I Open the ‘caffe-vs2013.sln’,why can’t I loaded caffe?It says” the project requires user input.Reload the project for more information”.Need I follow the step “Build Caffe in Windows with Visual Studio 2013 + CUDA 6.5 + OpenCV 2.4.9” before doing this?

    1. I didn’t test. But open with vs2012 might have some weird behavior. This solution is meant to skip to steps in previous post. But it’s not easy to provide solution file that works easily.
      If you only have vs2012. I suggest create a new vs2012 project. Drag same .cpp files in to the new project and include the 2 property sheet files in property manager accordingly.

      1. Thanks,now it works in VS2013!Though I can’t figure why,I’ll keep on seting up the matlab interface .

  2. Hi, I’m very close to the completion of this setup tutorial, but when I try to launch caffe.exe, it says my PC lacks libgfortran-3.dll. However, that’s not the worst part, when I download this .dll file and put it with caffe.exe, the .exe file still can not work 0.0. What m I supposed to do? Thanks in advance.

      1. I use dependency walker to check caffe.exe, it seems that two .dll files are missing, which r “API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL” and “EXT-MS-WIN-NTUSER-UICONTEXT-EXT-L1-1-0.DLL”. This error is due to that I m using win8.1 instead of lower versions of windows. Do u have these two .dll files? They r xtremely hard to find Orz

  3. Thanks Neil…..Your post was really helpful…I use GPU-NVIDIA Ge Force 820M (compute capability: 2.1), which is insufficient for cuDNN to work…..So, when I run examples, I get the error of “Check Failed: status == CUDNN_STATUS_SUCCESS (6 vs 0) CUDNN_STATUS_ARCH_MISMATCH” ……Is there any way I can work with your prebuilt binaries, without making use of cuDNN but running in GPU mode?

      1. Thans for your excellent post. In terms of CuDNN, I wonder where to put the MACRO “USE_CUDNN” in the exact place to enable CuDNN. CUDA C/C++ -> HOST -> Additional Compiler Options ?? CUDA Linker -> Command Line ??or other places.

      2. Hi, you can add “USE_CUDNN” in :
        Properties -> C/C++ -> Preprocessor -> PreprocessorDefinitions
        Enjoy 🙂

      3. by the shipmates as they tap into the third keg of beer. Here is a tip for Holly Graf, now that you are a short timer it would be unwise for you to leave your car unattended at the base. The real fun and payback is about to begin as Captain Holly Graf will be on the receiving end of mess deck justice. Go ahead Holly and see what will happen now if you take a swing at one of your sailors

  4. Thanks a lot for this great job. I did follow the instructions and caffe.exe works well. Nevertheless, when I try train-lenet-leveldb.bat I got this:
    net.cpp:274 The netstate phase(0) differed from the phase (1) specified by a rule in layer mnist
    leading to layer_factory.cpp:257 Layer mist has unspecified type.

    Any help would be welcome 🙂

    1. I’m having a same error. Debugging also shows that assertion fails
      assert(::caffe::LayerParameter_LayerType_IsValid(value)); // file caffe.pb.h, line 9239

      When I look at LayerParameter objects, I see the valid names of layers (‘mnist’, ‘conv1’, etc), but, the integer fields type_ all have garbage values.
      I believe it should be 5 for data layer, 4 for convolution, etc according to enum LayerParameter_LayerType.

      I’m afraid that protobuf isn’t parsed properly, though parsing functions return true.
      Because of this c++ LayerParameter objects are not filled correctly.

      I cannot debug protobuf parsing itself yet as it is in 3rd parties without debugging symbols.
      I’ll try to build it myself and look inside a bit later.

    2. Hey Arno,
      I saw that you also posted comments on the next part of this tutorial.
      Does this mean that you were able to solve this “Layer mnist has unspecified type” error? 🙂

      1. Hi,
        I replace all the type tag in the “lenet_train_test-leveldb.prototxt” and it works.
        Like 「type: DATA」 => 「 type: “data” 」

        My English is poor. hope you will understand what i mean…

    3. I met the same problem. And it is solved by replacing the protoc.exe in 3rdparty to version 2.6.0. (The provided protoc.exe is in version 2.6.1)

      1. I have tried replace the protoc.exe to version 2.6.0, but it still didn’t work….
        could you send your protoc file to me? Or contact me with detail in email?
        my email address is 65993366@qq.com, thanks!!!

  5. i got two error while compiling project in visual studio 2012

    1:-

    Error 34 error : namespace “std” has no member “signbit” L:\Caffe\caffe-vs2013\caffe\util\math_functions.hpp 143 1 caffe

    2:-

    Error 35 error MSB3721: The command “”L:\Caffe\cuda\soft\bin\nvcc.exe” -gencode=arch=compute_50,code=\”sm_50,compute_50\” –use-local-env –cl-version 2012 -ccbin “D:\Microsoft Visual Studio 11.0\VC\bin” -IL:\Caffe\cuda\soft\include -I”L:\Caffe\caffe-vs2013\\” -IL:\Caffe\boost_1_56_0 -IL:\Caffe\opencv\build\include -I”L:\Caffe\caffe-vs2013\3rdparty\include” -IL:\Caffe\cuda\soft\include -IL:\Caffe\cuda\soft\include -G –keep-dir Debug -maxrregcount=0 –machine 32 –compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_LIB -D_CRT_SECURE_NO_WARNINGS -DUSE_CUDNN -D_UNICODE -DUNICODE -Xcompiler “/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd ” -o Debug\math_functions.cu.obj “L:\Caffe\caffe-vs2013\caffe\src\caffe\util\math_functions.cu”” exited with code 2. C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 6.5.targets 593 9 caffe

    1. You can define your own signbit func like:
      inline bool signbit_temp(double num) { return _copysign(1.0, num) < 0; }

      and then replace std::signbit with signbit_temp and the compile would run.

  6. Thanks for your work, Neil.

    I’ve tried to build your solution with boost 1.58, but got linkage errors that 1.56 libs are missing.
    It appears that ‘leveldb.lib’ from your 3rd parties is already linked to some 1.56 libs, so boost version is not really configurable.

    I have also tried cuda 7 and had caffe.exe built. But then discovered that your tool ‘convert_mnist_data.exe’ still needs cuda 6.5 installed.

    Will you be able to add those 3rd party tools to your caffe solution, so that they can be built with same dependencies that are easy to switch?

      1. No-no, not prebuilt. I meant building them from source code too in the caffe solution.
        However, now I think it’s not too dificult to build them separately.

        Also, have you seen a problem that ‘Jason’, ‘arno’ and I are facing above?

      2. I’ve tried to build caffe 32bit version and build went ok (with lmdb and hdf5 disabled), but I can’t start it because there is no libopenblas.dll in win32 3rd party. lib files are there, but dll is missing (both debug and release).

        Can you please add those to your 3rd party? The prebuilt binaries from their website didn’t help. I’m not sure they are binary compatible.

  7. Hi Neil, I’m a beginner of caffe. I have successfully config the caffe according to your tutorial, that is I have got the “caffe.exe” and successfully open it. But when I train to train the Lenet(executing the “train_lenet-leveldb.bat”), at the end of cmd window shows

    I0824 23:13:42.736546 8136 solver.cpp:72] Creating training net from net file:
    examples/mnist/lenet_train_test-leveldb.prototxt
    I0824 23:13:42.743551 8136 net.cpp:274] The NetState phase (0) differed from th
    e phase (1) specified by a rule in layer mnist
    I0824 23:13:42.743551 8136 net.cpp:274] The NetState phase (0) differed from th
    e phase (1) specified by a rule in layer accuracy
    F0824 23:13:42.744551 8136 layer_factory.cpp:257] Layer mnist has unspecified t
    ype.
    *** Check failure stack trace: ***

    I speed lots of time still can’t figure it out, could you please tell me how to solve this problem?
    Thanks a lot!!!

  8. I have tried what Dragon and wddd mentioned, but it still didn’t work…
    T____T
    Layer mnist has unspecified type. T____T

    1. Hi toto chen,
      Had the same problem. I regenerated the caffe.pb.h and caffe_pretty_print.pb.h by running the GeneratePB.bat in the src/caffe/proto directory and I am not getting that error anymore. Hope that helps!

  9. Hi Neil

    i have a problem, so i need your help.

    i made the ‘caffe.exe’

    and it included the dll files,(opencv_ffmpeg300_64.dll,opencv_world300.dll, libglog.dll,libopenblas.dll,cudnn64_65.dll,msvcp120.dll,msvcr120.dll) in folder(C:\caffe-vs2013\caffe-vs2013\build\x64\Release)

    But when you run the ‘caffe.exe’,

    As soon as the window disappears while running.(compile 6 step)

    <>

    This line is not the my resultwindow.

    What is the problem?

  10. Same problem as mentioned a few times before :

    Created “caffe.exe” …

    Then calling “train_lenet-leveldb.bat” …

    Following lines are generated in command prompt :

    —–
    D:\Software\CNN\caffe-vs2013-master\caffe\examples\mnist>REM go to the caffe root

    D:\Software\CNN\caffe-vs2013-master\caffe\examples\mnist>cd ../../

    D:\Software\CNN\caffe-vs2013-master\caffe>set BIN=../build/x64/Release

    D:\Software\CNN\caffe-vs2013-master\caffe>”../build/x64/Release/caffe.exe” train –solver=examples/mnist/lenet_solver-leveldb.prototxt
    I0916 14:52:33.455509 6768 caffe.cpp:99] Use GPU with device ID 0
    I0916 14:52:33.921509 6768 common.cpp:21] System entropy source not available, using fallback algorithm to generate seed instead.
    I0916 14:52:33.921509 6768 caffe.cpp:107] Starting Optimization
    I0916 14:52:33.922509 6768 solver.cpp:37] Initializing solver from parameters:
    test_iter: 100
    test_interval: 500
    base_lr: 0.01
    display: 100
    max_iter: 10000
    lr_policy: “inv”
    gamma: 0.0001
    power: 0.75
    momentum: 0.9
    weight_decay: 0.0005
    snapshot: 5000
    snapshot_prefix: “examples/mnist/lenet”
    solver_mode: GPU
    net: “examples/mnist/lenet_train_test-leveldb.prototxt”
    I0916 14:52:33.929509 6768 solver.cpp:72] Creating training net from net file: examples/mnist/lenet_train_test-leveldb.prototxt
    I0916 14:52:33.930510 6768 net.cpp:274] The NetState phase (0) differed from the phase (1) specified by a rule in layer mnist
    I0916 14:52:33.930510 6768 net.cpp:274] The NetState phase (0) differed from the phase (1) specified by a rule in layer accuracy
    F0916 14:52:33.931509 6768 layer_factory.cpp:257] Layer mnist has unspecified type.
    *** Check failure stack trace: ***
    —–

    So, I get a crash while training.
    Did already run “GeneratePB.bat”in “\caffe-vs2013-master\caffe\src\caffe\proto” … didn’t make a difference.

    Why can’t I take the final step 😦

    1. Hi A. Pierce,

      After running GeneratePB.bat, you have to compile again. The reason is that you have to recompile so that all those header are copied into the source code and become part of the caffe.exe executable. I struggle with this a lot because my C++ knowledge was far from stellar but I hope this helps!

  11. Hello Neil,
    Thank you so much for sharing a wonderful work here…..
    I have follow all the your steps but i am getting two error

    1) 1>C:\Users\research01\Documents\Visual Studio 2013\Projects\caffe-vs2013-master\caffe/common.hpp(4): fatal error C1083: Cannot open include file: ‘boost/shared_ptr.hpp’: No such file or directory

    2) 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 6.5.targets(593,9): error MSB3721: The command “”C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\bin\nvcc.exe” -gencode=arch=compute_50,code=\”sm_50,compute_50\” –use-local-env –cl-version 2013 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64″ -I”C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include” -I”C:\Users\research01\Documents\Visual Studio 2013\Projects\caffe-vs2013-master\\” -I\include -I”C:\Users\research01\Documents\Visual Studio 2013\Projects\caffe-vs2013-master\3rdparty\include” -I”C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include” -I”C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include” –keep-dir x64\Release -maxrregcount=0 –machine 64 –compile -cudart static -DWIN32 -DNDEBUG -D_CONSOLE -D_LIB -DUSE_LEVELDB -DUSE_LMDB -DUSE_HDF5 -D_CRT_SECURE_NO_WARNINGS -DUSE_CUDNN -D_UNICODE -DUNICODE -Xcompiler “/EHsc /W3 /nologo /O2 /Zi /MD ” -o x64\Release\hdf5_data_layer.cu.obj “C:\Users\research01\Documents\Visual Studio 2013\Projects\caffe-vs2013-master\caffe\src\caffe\layers\hdf5_data_layer.cu”” exited with code 2.

    If you can suggest the solution i will be very grateful to you….

    1. above-mentioned problem solved…………. “caffe.exe”successfully generated but it gives system error like:

      caffe.exe – System error
      X The program can’t start because cudnn64_65.dll is missing from your computer. Try reinstalling the program to fix this problem….

      Any idea how to fix it…………….

  12. Hi, I have a gtx 460m, Fermi arch. I did everything correctly but when I ran the test, it always gives me a runtime error — Arch Mismatch. What’s going here? Why it is saying that?

  13. Hi Neil,
    First off all, thanks for the tutorial, very usefull.
    I have a simple question : what version of caffe do you use ?

      1. Thanks for your reply. Is it ok if I just turn off the GPU mode? Don’t I have to change any settings for CUDA? I cannot load ‘caffe’ project, and I think this is related with some settings for CUDA provided here. By the way, I cannot find MAke.config. Thanks!

      2. I really apologize,

        I was able to install caffe in both linux and windows. Make.config is something that belongs to the linux system. It is a very simple file with the setting that you can just turn on and off for compilation. I strongly suggest you do a dual-booth with linux/ubuntu and install caffe there since there are much more support for linux and ubuntu that with windows.

        I’m not really well-versed in Visual Studio, but I think there is a way to turn off CUDA for compilation. However, I will suggest to you to actually install CUDA v6.5 into your system. You can always turn it off when you actually run it. I will update to you back once I figured out how to turn CUDA compilation off for windows

  14. I cannot load ‘caff’ project. When I try to load it, I met the following message. I didn’t install CUDA, and I want to do this with CPU mode, but I don’t know how to do.

    Unable to read the project file “caffe.vcxproj”. C:\Users\MyName\Documents\Visual Studio 2013\Projects\caffe-vs2013-master\caffe\caffe.vcxproj(55,5): The imported project “C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCusomizations\CUDA 6.5.props” was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

  15. Thank you so much for your sharing. I met a problem when I used Boost_1_58 but not Boost_1_56 although I changed the path to find those 58.libs. It always said cannot open ***_56.lib. I wonder if there’s something calling those 56.libs but I failed to find out where it is. So I have to change back to Boost_1_56 and then problems solved. So would you please take a look at this if you have time?
    Thank you again for your patience and generosity.

  16. Hi,I met a problem described as follow:
    caffe/proto/caffe.pb.h(6953): error : namespace “google::protobuf::internal” has no member “GetEmptyStringAlreadyInited”
    How can I solve this problem

  17. Hi Neil,

    First, thank you for the great explanation for this tutorial. It really helps. When I open the file ‘caffe-vs2013.sln’, there are only two options of train and test-MNIST. I have no ‘caffe’ as it is shown in the picture. So, I am stuck in this stage, as I have no ‘caffe’ option:

    2. Right click on ‘caffe’ and click ‘Property’. In ‘General’ -> ‘Configuration Type’, make sure it’s ‘Application (.exe)’.

    I’d be very happy if you could help.

    1. Hello Faranak,

      I meet the same error with you.

      You can right click on ‘caffe’ to edit caffe.vcxproj, then check if all paths are correct for your own configuration.

      I meet this error because my CUDA’s version is 7.5 but not 6.5

  18. I can not download “3rdparty.zip” in my office. There is some firewall blocking here.
    Can you send me this file to me by e-mail?

  19. Hi Neal,

    I’m trying to compile the caffe project but I’m getting the following error:

    “Error 1 error LNK1112: module machine type ‘X86’ conflicts with target machine type ‘x64’ C:\CAFFE\caffe-vs2013-master\caffe\libboost_thread-vc120-mt-1_56.lib(thread.obj) caffe”

    I’m pretty sure I configured the Debug and Release files correctly… would you have some advice as to how I workaround this issue?

    Thank you! Serban

  20. Thanks alot,
    I could get everything to work but! I get a linking error! just this:
    error LNK1181: cannot open input file ‘libhdf5.lib’
    I set all library directories for the linker(Actually everything was pre-configured thanks to you), everything is there, I triple checked it! but still I get that linker error, do you know what could be causing it?

  21. Nice work! I just have a couple of issues/observations:

    It’s strange that your code compiles with vs2013. I tried it with vs2012 (which I’d expect to be virtually the same) and it fails because it does not find std::isnan, std::signbit and round(). (The first one isn’t really needed, and I had to the implement the other two by hand.)

    Your leveldb.lib in the 3rdparty folder is hardcoded to use Boost 1.56. (As in, it expects the existence of several library files called libboost_*-mt-1_56.lib.) For that reason, the project won’t link against any other version of Boost. This can be worked around by adding those library file names to “exclude default libraries” field in linker settings, and adding correct file names to linker input libraries.

    Even with that done, it still won’t link with VS2012 because I get linker conflicts between some pre-built objects and stuff that gets compiled on my end. I’m downloading VS2013 now.

    Your props file is looking for “opencv_world300.lib”. I haven’t tried OpenCV 3.0.0, but I have 2.4.9 and it does not have a opencv_world249.lib. The corresponding file is, I think, opencv_core249.lib.

    (That said, this is still far better than compiling caffe from source in Windows – tried to do that, it’s a dependency hell.)

    1. Looks like it can’t be linked with any Boost that’s not 1.56, even after messing with library exclusion settings. With all 1.56 libs explicitly excluded and 1.60 libs explicitly added to linker input, I get an odd error about boost::filesystem::path::generic_string() being defined in two places (once in leveldb.lib and once in libboost_filesystem-vc120-mt-1._60.lib). With libboost_filesystem-vc120-mt-1._60.lib not included, I get tons of undefined references.

      Trying to build boost 1.56 now…

      1. Builds correctly with 1.56. As for people above, train-lenet-leveldb.bat fails with “layer mnist has unspecified type”. Had to grab the source of protobuf, rebuild it manually, replace headers, libs and protoc.exe in 3rdparty, run caffe/src/caffe/proto/GeneratePB.bat, and recompile caffe. After that, it seems to work as intended.

  22. I am trying to compile caffe with VS2013 running in windows 7.
    The caffe project was built without any errors.
    When I tried to buld the train_MNIST project, i initially go a missing caffe.lib which went away after copying the
    caffe.lib to the train_MNIST release folder.
    On subsequent attempts to build, i get 16 unresolved references error like the one below:

    unresolved external symbol “public: virtual __cdecl caffe::SolverParameter::~SolverParameter(void)” (??1SolverParameter@caffe@@UEAA@XZ) train-MNIST.obj train-MNIST

    What is the problem and how can I fix it?.

  23. I am getting these errors while i am building:
    Error 33 error LNK1104: cannot open file ‘libboost_date_time-vc120-mt-1_56.lib’ C:\Users\ergolab\Documents\GitHub\caffe-vs2013-master\test-MNIST\LINK test-MNIST
    Error 34 error LNK1104: cannot open file ‘libboost_date_time-vc120-mt-1_56.lib’ C:\Users\ergolab\Documents\GitHub\caffe-vs2013-master\train-MNIST\LINK train-MNIST

  24. Hey Neil,

    you should think about typography. IMO your blog ist very hard to read. Maybe this grey and thin font should better be black.
    Think about it.

    Nice guide, btw.

    Greetings

  25. Guys who of you play Pokemon GO? Amazing game, finally Machamp has been caught
    using pokebusterbot. With this bot you can catch pokemons on autopilot!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s