ubuntu16.04下安装caffe2的安装

caffe2安装

安装前说明:到目前日期为止,大多数博客中介绍的方法是从 {git clone --recursive https://github.com/caffe2/caffe2.git} 中进行git代码,然而我们可以从git网站中看到这个caffe2.git已被移动到pytorch/pytorch repo。
caffe2已被移动搭到其他项目
因此,我们参考官方给出的安装说明来安装caffe2:https://caffe2.ai/docs/getting-started.html?platform=windows&configuration=compile

1)更新和安装依赖项

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 \
      python-dev \
      python-pip

这里注意,若 执行命令 sudo apt-get install libopencv-dev 报错,则采用以下命令解决:

sudo apt-get install build-essential make cmake git libgtk2.0-dev pkg-config python python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev libjpeg-dev libpng-dev libtiff-dev

2)pip安装常用lib

sudo python2 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --user \
      future \
      numpy \
      protobuf \
      typing \
      hypothesis

以上需要注意的是,将这些libs安装到了python2还是python3?我们这里是安装到了python2

# for Ubuntu 14.04
sudo apt-get install -y --no-install-recommends \
      libgflags2 \
      cmake3
# for Ubuntu 16.04
sudo apt-get install -y --no-install-recommends \
      libgflags-dev \
      cmake

以上需要注意的是,根据ubuntu版本选择安装命令。

3)安装显卡驱动、CUDA、cuDNN(在pytorch的caffe2版本需要cuda9.0+cudnn7.0以上)

输入以下命令,分别查看cuda和cudnn版本

nvcc -V
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

这里的nvidia-smi驱动的安装、CUDA、cuDNN的安装,最好不要安装caffe2的官方给出的方式安装,请参考https://blog.csdn.net/zbzb1000/article/details/52864131 ,安装CUDA9.0和cuDNN7.0

4)安装caffe2:

下载并且进入到pytorch目录:

git clone https://github.com/pytorch/pytorch.git && cd pytorch
git submodule update --init --recursive
python setup.py install

这里若在执行 {python setup.py install} 出现 Error:caffe2 requires CUDA9.0,则表示cuda版本不符合要求,需要返回第三步重新安装cuda9.0

5)测试:

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

交互得到success,则表示caffe2安装成功。
在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值