Successful build under windows but several improvement is needed
I have successfully build using MSVC 2015 with caffe 2. The installation instruction asks users to build with the .bat file in caffe2/scripts. However, I found this is not a good practice as sometimes we need use external dependencies. Configuring CMake with the GUI version would be much convenient under windows usage.
In Caffe windows version it will automatically download all dependency required in forms of pre-built library. It would be good if users want to quickly deploy Caffe.
For whom want to build from source, or using specific version of third party library, the submodule file format in Caffe 2 will much do the favor. But problem comes in when in CMake configuration.
Here is a temporary solution to build with customized CMake:
(Optional) Download prebuild libraries from previous version of Caffe
git clone https://github.com/BVLC/caffegit checkout windows- CMake, only need to configure
- All necessary binaries and libraries can found at
C:\Users\<username>\.caffe(Can be ignored if you choose step 0) Build protobuf, either from source (
caffe2/scripts/build_host_protoc.batwould be a fast build from source option, highly recommended.), or directly use the protobuf binary downloaded in step 0. If you need to build Caffe2 with shared library, you also need to build shared library in this step.CMake and specify
Protobuf_DIR.
- For step 0 users, point to
C:\Users\<username>\.caffe\dependencies\libraries_v140_x64_py27_1.1.0\libraries\cmake- For step 1 users, point to
/caffe2/build_host_protoc/cmake- For custom build users, point to folder containing
protobuf-config.cmakeOfficial suggested CMake is with
CMAKE_VERBOSE_MAKEFILEONBUILD_TESTOFFCMAKE_BUILD_TYPEReleaseUSE_CUDAOFF (turn ON if you want to build GPU version, need to install CUDA driver first)USE_NNPACOFFUSE_GLOGOFFUSE_GFLAGSOFFUSE_LMDBOFFUSE_LEVELDBOFFUSE_ROCKSDBOFFUSE_OPENCVOFF (suggested to turn this ON, but need to build OpenCV on your own, tested with OpenCV 3, OpenCV 2.4.13 may have problem on linking cudartlib, earlier version of OpenCV (possibily 2.4.11 or earlier) maybe a solution to linkage problem. This also happens in Linux)BUILD_SHARED_LIBSOFF (this option is under test, will cause compilation error if set to ON)BUILD_PYTHONOFF (Highly recommended to turn this ON unless you want to solely use C++ caffe2 interface)Specify all required dependency paths, similar to step 2
Configure and Generate
(VERY IMPORTANT)Note that CMakeLists.txt in current release does not properly configure protoc.exe, open
<caffe2-build>/CMakeCache.txt, add following line to the file nearProtobuf_DIR:
PROTOBUF_PROTOC_EXECUTABLE:FILEPATH=<protobuf-build>/bin/protoc.exeOpen
Caffe2.slnand build (Debug or Release)Build error would appear when building
lenghts_top_k_op.cc. At line 9 the type of y dimension need to change tointfromauto.Build again and enjoy Caffe2.
One thing I think the development group should notify is in operator_schema.h line 288, std::bind to std::function conversion. Though building is successful, but type conversion is not properly defined.
building with Gflags, Glog, LevelDB and Snappy is rather easy as well, under Windows VS2015 ... But remember you have to build only with MT Code generation option for all the 3rd part dependencies. Also, in order to make it work under python you will have to build ProtoBuf python source and add it to your PYTHONPATH. https://github.com/google/protobuf/releases/download/v3.2.0/protobuf-python-3.2.0.zip.
Also, it is recommended to use MKL for blas (for CPU purposes at least).
I am having a hard time achieving Good run times when using CUDA and CUDNN, has anybody managed to achieve good run time in that ? See performance evaluation i did: https://github.com/caffe2/caffe2/issues/921
@ugionet - how did you get gflags/glog/leveldb to build? Any time I deviate from the default settings (USE_GLOG OFF, USE_GFLAGS=OFF, USE_LEVELDB=OFF), I get thousands of linker errors. When you say "build only with MT Code generation" for all 3rd party dependencies, where do I specify that?
@ctraina I'm sure you've solved this problem by now, but you can configure options in VS.
In Solution Explorer, right click on project name and go to properties -> C/C++ -> Code Generation Change the option under 'Runtime Library'.
https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx