1. 程式人生 > >CentOS7安裝Caffe2

CentOS7安裝Caffe2

安裝epel

$ sudo yum install epel-release

安裝依賴的系統庫

# $ sudo yum update
$ sudo yum install -y \
automake \
cmake3 \
gcc \
gcc-c++ \
git \
kernel-devel \
leveldb-devel \
lmdb-devel \
libtool \
protobuf-devel \
python-devel \
python-pip \
snappy-devel \
gflags-devel \
glog-devel

安裝依賴的 Python 庫

$ sudo pip install --upgrade pip
$ sudo pip install \
flask \
future \
graphviz \
hypothesis \
jupyter \
matplotlib \
numpy \
protobuf \
pydot \
python-nvd3 \
pyyaml \
requests \
scikit-image \
scipy \
setuptools \
six \
tornado

編譯安裝 caffe2

$ git clone --recursive https://github.com/caffe2/caffe2
$ 
cd caffe2 && mkdir build $ cd build && cmake3 .. $ sudo make install

測試

首先使用下面的命令來檢查 caffe2 是否安裝成功

$ cd build
$ python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"

如果 caffe2 安裝成功,上面的命令應該列印 Success。

其次使用下面的命令來執行一個測試

$ cd build
$ python -m caffe2.python
.operator_test.relu_op_test $ python -m caffe2.python.operator_test.weighted_sample_test $ python -m caffe2.python.examples.resnet50_trainer --train_data null --use_cpu true

問題

問題一

執行 “python -m caffe2.python.operator_test.relu_op_tes” 報錯

...
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/jhadmin/Downloads/caffe2/build/caffe2/python/operator_test/relu_op_test.py", line 22, in <module>
    from hypothesis import given
  File "/usr/lib/python2.7/site-packages/hypothesis/__init__.py", line 31, in <module>
    from hypothesis.core import given, find, example, seed, reproduce_failure, \
  File "/usr/lib/python2.7/site-packages/hypothesis/core.py", line 34, in <module>
    from coverage.files import canonical_filename
ImportError: cannot import name canonical_filename

問題原因是 Python 的 coverage 版本問題,升級 coverage 庫

sudo pip install coverage --upgrade

問題二

執行 “python -m caffe2.python.operator_test.relu_op_tes” 報錯

AttributeError: 'module' object has no attribute 'full'

問題原因是 numpy 版本問題,升級 numpy 庫

sudo pip install numpy --upgrade