Info on building Caffe 2 from source
Basically, follow official instruction here (with some modifications).
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
git \
libgoogle-glog-dev \
libgtest-dev \
libiomp-dev \
libleveldb-dev \
liblmdb-dev \
libopencv-dev \
libopenmpi-dev \
libsnappy-dev \
libprotobuf-dev \
openmpi-bin \
openmpi-doc \
protobuf-compiler \
libgflags-dev \
cmake
sudo pip3 install \
future \
numpy \
protobuf \
typing \
hypothesis \
pyyaml \
pydot
Under ~/src
, run the following:
git clone https://github.com/pytorch/pytorch.git && cd pytorch
git checkout db5d313
git submodule update --init --recursive
CC=/usr/bin/gcc-5 CXX=/usr/bin/g++-5 python3 setup.py install
Check whether build was successful or not
python3 -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
Test a module.
python3 caffe2/python/operator_test/activation_ops_test.py
pip3 install -r requirements.txt --user
- https://www.macports.org/install.php
- https://distfiles.macports.org/MacPorts/MacPorts-2.5.4-10.14-Mojave.pkg
sudo port install cmake gflags
conda create -n caffe
conda activate caffe
conda install future \
numpy \
protobuf \
typing \
hypothesis \
pyyaml \
pydot
conda create -n caffe36
conda activate caffe36
conda install future \
numpy \
protobuf \
typing \
hypothesis \
pyyaml \
pydot
git clone https://github.com/pytorch/pytorch.git && cd pytorch
git submodule update --init --recursive
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install
https://github.com/pytorch/pytorch#from-source
export DYLD_LIBRARY_PATH=`python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"`/caffe2/python
After using it, you can unset DYLD_LIBRARY_PATH
by
unset DYLD_LIBRARY_PATH