Here's my attempt at wrapping Caffe2 C++ library with Golang CGO.
Note: Caffe2 is now a part of pytorch library, so we need to compile it from pytorch repository
gitmake- And other requirements for the Caffe2/Pytorch library & Intel MKL-DNN library.
-
Clone the
pytorchgit repository & compile it.$ git clone https://github.com/pytorch/pytorch # Cloning... $ cd pytorch $ git checkout v1.0.1 # I currently test using this version # Compile it
-
(Depends on the pytorch build flags) Clone the
mkl-dnngit repository & get the external header files.$ https://github.com/intel/mkl-dnn # Cloning... $ cd mkl-dnn $ git checkout v0.18.1 # I currently test using this version # Compile it
-
Clone this repository.
$ git clone --depth=1 https://github.com/taufik-rama/caffe2-go-binding # Cloning... -
Copy all of the
torchpackage include file (should be ontorch/lib/include/) intocaffe2/include-pytorch/# On pytorch directory after compilation $ cp -r torch/lib/include/* /path/to/caffe2/include-pytorch/
-
Copy
libc10.so&libcaffe2.sofrompytorchbuild result (should be onbuild/lib/) intocaffe2/lib/directory.# On pytorch directory after compilation $ cp build/lib/libc10.so build/lib/libcaffe2.so /path/to/caffe2/lib/ -
Copy all of the
mkl-dnnexternal header file (should be onexternal/mkl{xx}/include/) intocaffe2/include-mkl# On pytorch directory after compilation $ cp external/mkl{xx}/include/* /path/to/caffe2/include-mkl/
-
Compile the C project
$ cd caffe2 && make # Compiling...
-
Build the Go package normally
$ go build # Compiling...