Note that now that BVLC’s caffe repository directly supports compilation on Windows, this guide has become obsolete.
When attempting to check out Caffe after some wasted hours of getting TensorFlow to run on Windows (which sort-of works using Bash for Windows), I gave Caffe a try. However, the last time I tried to get a huge system of nested dependencies using CMake to work on Windows, things only got worse with every additional project. For Caffe, you’d need Boost, OpenCV, HDF and protobuf as well as some Google logging and command-line argument things amongst other stuff — and boy, make sure you got your linking, threading and runtime right, and don’t even think about mixing different C++ or Boost flavors.
So there’s this Windows fork of Caffe managed by Microsoft which apparently only requires you to configure the CommonSettings.props
file to your liking and then compile. The nice part is, all references are pulled using NuGet. The bad part is, the packages are all MSVC 1800, i.e. Visual Studio 2013. You’ll be able to find newer variants of Boost, but that’s about it.
If you’re really trying to use Visual Studio 2015, fix the nuget.config
to have the repository path fixed like described in this StackOverflow answer:
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://www.nuget.org/api/v2/" /> </packageSources> <add key="repositoryPath" value="..\..\NugetPackages" /> </configuration>
Also note that the path is most likely outside your build tree … but that’s how it is provided by the maintainer.
I wasted another day trying to get Caffe to work in Visual Studio 2015 by selecting the 2013 toolkit but, in the end, it came down to the following error:
NuGet error: unknown command 'overlay'
This overlay
stuff apparently is some NuGet 2 magic that didn’t survive the dark ages, so it won’t work with NuGet 3, which I have in my path and which is also used internally by VS 2015.
There are a couple of questions regarding that error, like this one on the OpenCV Answers site, issues on GitHub (with half-broken answers since the CoApp tooling doesn’t really work exist anymore), etc., but there’s no obvious solution — at least if you’re using a modern Windows development environment — that is, one that’s using NuGet 3 instead of NuGet 2.6.
You can fix most of the problems by just upgrading OpenCV 2 to OpenCV 3. For that, kick out the old NuGet packages and reference the opencvdefault one as shown in this video. But even if you do that, it’ll fail on the glog 0.3.3 NuGet package which still uses overlays.
As it turns out though, the NuGet package for glog 0.3.3 already contains a NuGet binary at glog.0.3.3.0/build/native/private/nuget.exe
, but since it’s not in the path, it won’t use it. Copy that to the package’s root (where NuGet-Overlay.cmd
can be found and you’re set.
For the rest, make sure you’re using Python 2.7 though, as the Boost libraries are requiring that; also install NumPy.
Using e.g. Anaconda Python, you’d want
conda create -n caffe python=2.7 numpy
Which will leave you with the task to find python27_d.lib
… or just build Release
.