Building Caffe (1.0) for Windows - t-kuha/caffe-win-dependency GitHub Wiki

This is an instruction for how to build Caffe (static version) from source.

0. Requirement


1. Get source

  • Clone Caffe source from my GitHub:

    > git clone https://github.com/t-kuha/caffe.git
    
    # Check out Windows branch
    > cd caffe
    > git checkout windows
    
    # You can run "git status" to make sure you're on "windows" branch 
    
    # Go back to the original direcroty
    > cd ..
  • Download dependency files from my repo:

    # Add --recursive if you also want sources
    > git clone https://github.com/t-kuha/caffe-win-dependency.git
    
    # Checkout necessary version
    > cd caffe-win-dependency
    > git checkout python-3.7
    > cd ..

2. Build

# Run build command
> mkdir _build
> cd _build

# Build with VS2017
# CPU-only version
> ..\caffe-win-dependency\build_caffe.cmd <Full path to root dir>/caffe-win-dependency/_vs2017
# GPU version
> ..\caffe-win-dependency\build_caffe_gpu.cmd <Full path to root dir>/caffe-win-dependency/_vs2017

3. Run

3.1 Python

  • Copy _< Build directory >/install/python/caffe to /Lib/site-packages

  • Check if Caffe works in Python:

> python -c "import caffe"

3.2 Command Line - Run MNIST Example

  • Check if command line tool works:
> cd < Build directory >/_install
> bin/caffe.exe
caffe.exe: command line brew
usage: caffe <command> <args>

commands:
  train           train or finetune a model
  test            score a model
  device_query    show GPU diagnostic information
  time            benchmark model execution time

  No modules matched: use -help
  • Copy < Caffe Source >\examples into < Build directory >_install

  • Download MNIST data & Convert it to LMDB

> bin\convert_mnist_data.exe examples\mnist\t10k-images.idx3-ubyte examples\mnist\t10k-labels.idx1-ubyte examples/mnist/mnist_test_lmdb
> bin\convert_mnist_data.exe examples\mnist\train-images.idx3-ubyte examples\mnist\train-labels.idx1-ubyte examples/mnist/mnist_train_lmdb
  • Train
> bin\caffe.exe train --solver=examples\mnist\lenet_solver.prototxtc
    ...
I0410 13:52:01.257920  3040 solver.cpp:447] Snapshotting to binary proto file examples/mnist/lenet_iter_10000.caffemodel
I0410 13:52:01.268927  3040 sgd_solver.cpp:273] Snapshotting solver state to binary proto file examples/mnist/lenet_iter_10000.solverstate
I0410 13:52:01.274931  3040 solver.cpp:310] Iteration 10000, loss = 0.00263578
I0410 13:52:01.275933  3040 solver.cpp:330] Iteration 10000, Testing net (#0)
I0410 13:52:01.402025  9560 data_layer.cpp:73] Restarting data prefetching from start.
I0410 13:52:01.407029  3040 solver.cpp:397]     Test net output #0: accuracy = 0.992
I0410 13:52:01.407029  3040 solver.cpp:397]     Test net output #1: loss = 0.0278062 (* 1 = 0.0278062 loss)
I0410 13:52:01.407029  3040 solver.cpp:315] Optimization Done.
I0410 13:52:01.407029  3040 caffe.cpp:260] Optimization Done.
⚠️ **GitHub.com Fallback** ⚠️