注意,目前caffe2只支持Python2,所以安装caffe2的时候需要在电脑上创建一个Python2的虚拟环境。然后安装opencv,再安装caffe2.
现在开始说caffe2的步骤:
1:安装依赖库:
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
libgoogle-glog-dev \
libprotobuf-dev \
protobuf-compiler \
python-dev \
python-pip
sudo pip install numpy protobuf
sudo apt-get install -y --no-install-recommends libgflags2
sudo apt-get install -y --no-install-recommends \
libgtest-dev \
libiomp-dev \
libleveldb-dev \
liblmdb-dev \
libopencv-dev \
libopenmpi-dev \
libsnappy-dev \
openmpi-bin \
openmpi-doc \
python-pydot
sudo pip install \
flask \
graphviz \
hypothesis \
jupyter \
matplotlib \
pydot python-nvd3 \
pyyaml \
requests \
scikit-image \
scipy \
setuptools \
tornado
2.下载caffe2 。注意一定要使用clone指令,不能直接下载
git clone --recursive https://github.com/caffe2/caffe2.git && cd caffe2
make && cd build && sudo make install
python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
python -m caffe2.python.operator_test.relu_op_test
3.设置环境变量:
```bash
echo $PYTHONPATH
# export PYTHONPATH=/usr/local:$PYTHONPATH
# export PYTHONPATH=$PYTHONPATH:/root/caffe2/build
echo $LD_LIBRARY_PATH
# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
```