Caffe2 RHEL 7.3 安装

配置yum源

sudo vim /etc/yum.repos.d/epel.repo

设置 enabled=1 这样才会找到cmake3 leveldb-devel lmdb-devel.

更新yum并安装依赖

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 和 glog 在yum里找不到,需要从源码安装

git clone https://github.com/gflags/gflags.git && \
cd gflags && \
mkdir build && cd build && \
cmake3 -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS='-fPIC' .. && \
make -j 8 && sudo make install && cd ../.. && \
git clone https://github.com/google/glog && \
cd glog && \
mkdir build && cd build && \
cmake3 -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS='-fPIC' .. && \
make -j 8 && sudo make install && cd ../..
yum install gflags-devel glog-devel

安装python依赖库

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

下载源码并编译

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

测试

python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
python -m caffe2.python.operator_test.relu_op_test

将caffe2的python接口路径添加到系统环境变量

[root@localhost caffe]# vim /etc/profile
在文件的最后一行添加:
export PYTHONPATH=/usr/local:$PYTHONPATH
export PYTHONPATH=$PYTHONPATH:/home/ubuntu/caffe2/build
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH #注意,/home/ubuntu/caffe2/build这部分要根据你的实际目录来填写。/opt/caffe2/build

然后使修改生效
[root@localhost caffe]# source /etc/profile

你可能感兴趣的:(Caffe2 RHEL 7.3 安装)